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();
}
}