cheng_312
路人甲
路人甲
  • 注册日期2006-06-06
  • 发帖数48
  • QQ
  • 铜币273枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2159回复:4

两个面文件的面积比例问题?

楼主#
更多 发布于:2006-12-25 10:47
<P>两个面文件(shape格式)A和B,其中B有多块,每一块空间位置都与A部分重叠或完全重叠,怎样可以快速的计算出每一块与A重叠部分面积占本块总面积的比例。</P>

<P>意思是想把一定面积比例的选出来,能做到吗,谢谢各位哦。</P>
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15945
  • QQ554730525
  • 铜币25337枚
  • 威望15352点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2006-12-25 18:50
<H1>IBasicGeoprocessor Intersect Example</H1><PRE><P>The following VBA code uses <STRONG>IBasicGeoprocessor::Intersect</STRONG> method to overlay an input layer with the polygons of an overlay layer so that the resulting output layer a) has the combined attribute data of the features in the two inputs, and b) only contains featuresthat fall within the spatial extent of the overlay polygons. The output is saved as a shapefile in the temp directory of the C drive (C:\temp).</P>
<P><STRONG>How to Use:</STRONG></P>
<OL>
<LI>Paste the code into VBA.
<LI>Add two layers to the map. The first layer is the input layer. This is the layer whose features will be intersected. The feature type of this layer can be lines or polygons. The second layer is the overlay layer. The features of this layer must be polygons. You can adjust the code accordingly if you wish to interactively select the layer you wish to intersect, or to select the layer you want to use as the overlay layer, or to use the selected features from the input layer, the overlay layer, or the selected features from both layers.
<LI>The VBA code creates a new shapefile called Intersect_result. You can adjust the code to specify a different name for the output or to save the result to a geodatabase.
<LI>Run the code.</LI></OL>
<P><CODE><PRE>Option Explicit<BR>Public Sub Intersect()<BR>  ' Get the input layer and feature class<BR>  Dim pMxDoc As IMxDocument<BR>  Set pMxDoc = ThisDocument<BR>  Dim pLayer As ILayer<BR>  Set pLayer = pMxDoc.FocusMap.Layer(0)<BR>  Dim pInputFeatLayer As IFeatureLayer<BR>  Set pInputFeatLayer = player<BR>  ' Use the Itable interface from the Layer (not from the FeatureClass)<BR>  Dim pInputTable As ITable<BR>  Set pInputTable = player<BR>  ' Get the input feature class.<BR>  ' The Input feature class properties, such as shape type,<BR>  ' will be needed for the output<BR>  Dim pInputFeatClass As IFeatureClass<BR>  Set pInputFeatClass = pInputFeatLayer.FeatureClass<BR>  ' Get the overlay layer<BR>  ' Use the Itable interface from the Layer (not from the FeatureClass)<BR>  Set pLayer = pMxDoc.FocusMap.Layer(1)<BR>  Dim pOverlayTable As ITable<BR>  Set pOverlayTable = pLayer<BR>  ' Error checking<BR>  If pInputTable Is Nothing Then<BR>    MsgBox "Table QI failed"<BR>    Exit Sub<BR>  End If<BR>  If pOverlayTable Is Nothing Then<BR>    MsgBox "Table QI failed"<BR>    Exit Sub<BR>  End If<BR>  ' Define the output feature class name and shape type (taken from the<BR>  ' properties of the input feature class)<BR>  Dim pFeatClassName As IFeatureClassName<BR>  Set pFeatClassName = New FeatureClassName<BR>  With pFeatClassName<BR>    .FeatureType = esriFTSimple<BR>    .ShapeFieldName = "Shape"<BR>    .ShapeType = pInputFeatClass.ShapeType<BR>  End With<BR>  ' Set output location and feature class name<BR>  Dim pNewWSName As IWorkspaceName<BR>  Set pNewWSName = New WorkspaceName<BR>  pNewWSName.WorkspaceFactoryProgID = "esriCore.ShapeFileWorkspaceFactory.1"<BR>  pNewWSName.PathName = "C:\temp"<BR>  Dim pDatasetName As IDatasetName<BR>  Set pDatasetName = pFeatClassName<BR>  pDatasetName.Name = "Intersect_result"<BR>  Set pDatasetName.WorkspaceName = pNewWSName<BR>  ' Set the tolerance. Passing 0.0 causes the default tolerance to be used.<BR>  ' The default tolerance is 1/10,000 of the extent of the data frame's spatial domain<BR>  Dim tol As Double<BR>  tol = 0#< BR >   <FONT color=green>' Perform the intersect</FONT><BR>  Dim pBGP As IBasicGeoprocessor<BR>  Set pBGP = New BasicGeoprocessor<BR>  Dim pOutputFeatClass As IFeatureClass<BR>  Set pOutputFeatClass = pBGP.intersect(pInputTable, False, pOverlayTable, False, _<BR>    tol, pFeatClassName)<BR>  ' Add the output layer to the map<BR>  Dim pOutputFeatLayer As IFeatureLayer <BR>  Set pOutputFeatLayer = New FeatureLayer<BR>  Set pOutputFeatLayer.FeatureClass = pOutputFeatClass<BR>  pOutputFeatLayer.Name = pOutputFeatClass.AliasName<BR>  pMxDoc.FocusMap.AddLayer pOutputFeatLayer<BR>End Sub</PRE></CODE></PRE>
举报 回复(0) 喜欢(0)     评分
cheng_312
路人甲
路人甲
  • 注册日期2006-06-06
  • 发帖数48
  • QQ
  • 铜币273枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-12-26 11:13
<P>哦,谢谢啊!但没用过vb,能用中文解释下具体怎么操作吗?</P>
举报 回复(0) 喜欢(0)     评分
cheng_312
路人甲
路人甲
  • 注册日期2006-06-06
  • 发帖数48
  • QQ
  • 铜币273枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-12-26 11:25
<P>tol = 0#< BR >   ' Perform the intersect</P>
<P>似乎有错误</P>
举报 回复(0) 喜欢(0)     评分
cheng_312
路人甲
路人甲
  • 注册日期2006-06-06
  • 发帖数48
  • QQ
  • 铜币273枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2006-12-27 08:34
<P>tol = 0#< BR >   ' Perform the intersect</P>
<P>提示这句有错误哦</P>
<P>能具体说下怎么操作吗?</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部