1、在ArcMAP中操作。
在编辑状态下,选中所有的线,然后使用高级编辑工具条上的Split Polygons即可,参见下图。
该接口发布与适用于ArcGIS 9.3中,9.2 版本也存在。以下是IFeatureConstruction接口参数:
IEnumFeature:它将是构造多边形的线源。
Processing bounds:处理范围,目标面范围。
invalidArea:无效的区域对象,它是可选的,可用于重绘受处理影响的区域-在某些情况下,可能需要使无效的区域有效,以便相关特征(注释,路径符号等)正确重绘。
ClusterTolerance:该值必须至少与与目标面要素类关联的空间参考的聚类容差一样大。可以为该参数传递值–1,表示将使用目标要素类的空间参考。
/// <summary>
/// 地图控件中选中线分割面
/// </summary>
public static void SplitPolygonsWithLines()
{
IFeatureLayer polygonLayer = axMapControl1.get_Layer(1) as IFeatureLayer;
IFeatureClass polygonFeatureClass = polygonLayer.FeatureClass;
IEnvelope envelope = (polygonFeatureClass as IGeoDataset).Extent;
IEnumFeature enumLineFeature = axMapControl1.Map.FeatureSelection as IEnumFeature;
IFeatureConstruction featureCon = new FeatureConstructionClass();
featureCon.SplitPolygonsWithLines(null, polygonFeatureClass, envelope, enumLineFeature, null, -1);
}
/// <summary>
/// 线图层切割面图层
/// </summary>
/// <param name="polygonFC">面图层</param>
/// <param name="lineFC">线图层</param>
public static void SplitPolygonsWithLinesFromCursor(IFeatureClass polygonFC, IFeatureClass lineFC)
{
//Set IFeatureCursor object, which will be the line source to construct polygons.
IFeatureCursor lineFeatureCursor = lineFC.Search(null, false);
//Set the processing bounds to be the extent of the polygon feature class,
//which will be used to search for existing polygons in the target feature.
IGeoDataset geoDS = polygonFC as IGeoDataset;
IEnvelope processingBounds = geoDS.Extent;
//Define an IInValidArea object.
IInvalidArea invalidArea = new InvalidAreaClass();
//Define a construct feature object.
IFeatureConstruction featureConstruction = new FeatureConstructionClass();
//Start an edit session.
IDataset dataset = polygonFC as IDataset;
IWorkspace workspace = dataset.Workspace;
IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;
if (workspaceEdit.IsBeingEdited() != true)
{
workspaceEdit.StartEditing(true);
workspaceEdit.StartEditOperation();
}
try
{
featureConstruction.SplitPolygonsWithLinesFromCursor(null, polygonFC, processingBounds, lineFeatureCursor, invalidArea, -1);
//Complete the edit operation and stop the edit session.
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);
}
catch (Exception e)
{
//Abort the edit operation if errors are detected.
System.Console.WriteLine("Construct polygons failed. " + e.Message);
workspaceEdit.AbortEditOperation();
}
}