如何在c#中的arcmap中获取lat长度的图层范围

时间:2014-06-11 04:19:31

标签: c# arcgis arcmap

我需要在c#中的Arcmap中获取图层纬度和经度的范围或边界框。

我最初使用了以下代码,但它并不总是在lat long中给出范围:

public IEnvelope GetExtent(IFeatureLayer PolygonLayer) {
    return PolygonLayer.AreaOfInterest.Envelope;
}

1 个答案:

答案 0 :(得分:2)

我有一个解决方法。必须预测程度。

public ISpatialReference CreateSpatialRefGCS(ESRI.ArcGIS.Geometry.esriSRGeoCSType gcsType)
{
    ISpatialReferenceFactory spatialRefFactory = new SpatialReferenceEnvironmentClass();
    IGeographicCoordinateSystem geoCS = spatialRefFactory.CreateGeographicCoordinateSystem((int)gcsType);
    return (ISpatialReference)geoCS;
}

public IEnvelope GetExtent(IFeatureLayer PolygonLayer) {
    IEnvelope envelope = PolygonLayer.AreaOfInterest.Envelope;
    envelope.Project(CreateSpatialRefGCS(esriSRGeoCSType.esriSRGeoCS_WGS1984));
    return PolygonLayer.AreaOfInterest.Envelope;
}