In ArcMap I have a SpatialReference EPSG 32633 of the Dataframe and a Layer(Shape) loaded with EPSG 31494. Now I want to get the Extent of the original underlying Data. So I take my Layer as IGeoDataset:
ESRI.ArcGIS.Geometry.ISpatialReference spatialReference = (pLayer as IGeoDataset).SpatialReference; ESRI.ArcGIS.Geometry.IEnvelope envelope = (pLayer as IGeoDataset).Extent;
The SpatialReference is 31494, but the Extent shows me the Coordinates in EPSG 32633.
In the Properties-Dialog of the Layer the Extent shows the Coordinates in 31494. How can I get these Coordinates?
The spatial reference of a feature layer in the map and the spatial reference of that layer's data source are not necessarily the same. To get the spatial reference of the data source you need to access the data source itself. You can get a reference to a feature layer's data source via IFeatureLayer.FeatureClass.
Dear Neil, thank you for watching my problem. I knew that the Spatial References of the Map and the Layer are not the same, this is just the reason of my question. I access the correct SpatialReference (this from the Shape) over the Interface IGeoDataset, which should show me the underlying Datasource. But the member 'Extent' of the IGeoDataset doesn't show it in the right Spat.Ref. Could this be a bug? In an older Forum-Discussion is shown also the way over the IGeoDataset. I searched the FeatureClass and the FeatureClass.FeatureDataset but can't find an envelope there.