Select to view content in your preferred language

How do I get the coordinate system of a feature class?

1318
2
Jump to solution
09-18-2019 09:35 AM
SamRideout1
Occasional Contributor

I am using C# to perform some analysis steps.  My Buffer step fails due to output geometry domain.  I have replicated the failure manually and have found that if I have an output coordinate system assigned, then the buffer processes correctly.  So, I want to get the coordinate system from one of the input layers to assign to the buffer execution.   Does anybody know how to get the coordinate system from a polygon layer or a raster layer?

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi Sam,

For raster layers:

 // Working with rasters requires the MCT.
 await QueuedTask.Run(() =>
 {
     // Get the raster from the current selected raster layer.
     Raster inputRaster = currentRasterLayer.GetRaster();
     var spatRef= inputRaster.GetSpatialReference();
});

For feature layers:

// Working with rasters requires the MCT.
await QueuedTask.Run(() =>
{
 // get the feature class associated with the layer
 var featureClass = pointFeatureLayer.GetTable() as FeatureClass;
 // retrieve the class definition of the point feature class
 var classDefinition = featureClass.GetDefinition() as FeatureClassDefinition;

 // store the spatial reference as its own variable
 var spatialReference = classDefinition.GetSpatialReference();
});

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi Sam,

For raster layers:

 // Working with rasters requires the MCT.
 await QueuedTask.Run(() =>
 {
     // Get the raster from the current selected raster layer.
     Raster inputRaster = currentRasterLayer.GetRaster();
     var spatRef= inputRaster.GetSpatialReference();
});

For feature layers:

// Working with rasters requires the MCT.
await QueuedTask.Run(() =>
{
 // get the feature class associated with the layer
 var featureClass = pointFeatureLayer.GetTable() as FeatureClass;
 // retrieve the class definition of the point feature class
 var classDefinition = featureClass.GetDefinition() as FeatureClassDefinition;

 // store the spatial reference as its own variable
 var spatialReference = classDefinition.GetSpatialReference();
});

SamRideout1
Occasional Contributor

Thank you Gintautas......  just what I needed!!