是否可以返回多边形图层的边界(外部)周长?
假设您有美国的地图,为简单起见,细分为县级地图,是否可以从该地图中返回整个国家的边界地图?
是否可以返回多边形图层的边界(外部)周长?
假设您有美国的地图,为简单起见,细分为县级地图,是否可以从该地图中返回整个国家的边界地图?
Answers:
您可以在县图层上进行溶解(请确保只选择了要溶解的县)。
public static IPolygon getPolygonFromLayer(ILayer layer)
{
IFeatureLayer FLayer = layer as IFeatureLayer;
IFeatureClass FClass = FLayer.FeatureClass;
return polygonMerge(FClass);
}
private static IPolygon polygonMerge(IFeatureClass featureClass)
{
if (featureClass == null) return null;
IGeoDataset geoDataset = featureClass as IGeoDataset;
//You can use a spatial filter to create a subset of features to union together.
//To do that, uncomment the next line, and set the properties of the spatial filter here.
//Also, change the first parameter in the IFeatureCursor.Seach method.
//ISpatialFilter queryFilter = new SpatialFilterClass();
IGeometry geometryBag = new GeometryBagClass();
//Define the spatial reference of the bag before adding geometries to it.
geometryBag.SpatialReference = geoDataset.SpatialReference;
//Use a nonrecycling cursor so each returned geometry is a separate object.
IFeatureCursor featureCursor = featureClass.Search(null, false);
IGeometryCollection geometryCollection = geometryBag as IGeometryCollection;
IFeature currentFeature = featureCursor.NextFeature();
while (currentFeature != null)
{
//Add a reference to this feature's geometry to the bag.
//Since you don't specify the before or after geometry (missing),
//the currentFeature.Shape IGeometry is added to the end of the geometryCollection.
object missing = Type.Missing;
geometryCollection.AddGeometry(currentFeature.Shape, ref missing, ref missing);
currentFeature = featureCursor.NextFeature();
}
// Create the polygon that will be the union of the features returned from the search cursor.
// The spatial reference of this feature does not need to be set ahead of time. The
// ConstructUnion method defines the constructed polygon's spatial reference to be the
// same as the input geometry bag.
ITopologicalOperator unionedPolygon = new PolygonClass();
unionedPolygon.ConstructUnion(geometryBag as IEnumGeometry);
return unionedPolygon as IPolygon;
}
}
听起来好像在arcgis.com上发布的“ 边界容器”示例可以满足您的需求。
您可能还正在寻找以前称为DROPLINE的功能。
尽管从ArcInfo Workstation过渡到ArcGIS Desktop仍然无法幸免,但是目前有一个ArcGIS Idea可以还原它:
最好选择在指定字段具有相同值的多边形之间放置线。此功能以前在ArcPlot中作为DROPLINE命令可用,并且被广泛用作避免使用dissolve命令创建新数据集的方法。