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?
Solved! Go to Solution.
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();
});
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();
});
Thank you Gintautas...... just what I needed!!