mgallisandassociates

Convert feature class to raster

Discussion created by mgallisandassociates on Jun 21, 2011
Latest reply on Jul 1, 2011 by Hornbydd

  1. 1

I have made a tool which converts a feature class to a raster using IRasterConvertHelper and ToRaster1. 

IRaster pRaster;
IRasterConvertHelper rch = new RasterConvertHelper();
IGeoDataset pGeoDS_Bag = (IGeoDataset)pFClass_Bag;
string strFormat = "GRID";

ESRI.ArcGIS.GeoAnalyst.IRasterAnalysisEnvironment rasterAnalysisEnvironment = (ESRI.ArcGIS.GeoAnalyst.IRasterAnalysisEnvironment)new RasterAnalysis();

rasterAnalysisEnvironment.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, object_cellSize);

rasterAnalysisEnvironment.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref object_envelope, ref object_snapraster);

IFeatureClassDescriptor pFCD = (IFeatureClassDescriptor)new FeatureClassDescriptor();
pFCD.Create(pFClass_Bag, null, pFClass_Bag.Fields.Field[iFieldIndx].Name);

pRaster = rch.ToRaster1(pFCD as IGeoDataset, strFormat, rasterAnalysisEnvironment);



The tool works when the spatial reference of the feature class is a projected spatial reference.  However, when the feature class has a geographic spatial reference the tool fails, providing no information except that the error was a general error.

How do I make IRasterConvertHelper work when the feature class has a geographic spatial reference? 


  1. 2

Also, just in case the above question cannot be answered, how do I execute a conversion tool, specifically ESRI.ArcGIS.ConversionTools.FeatureToRaster?  It seems that this tool should be the same as that which is provided to the UI user through Conversion Tools of ArcToolBox and, thus, should handle using an input feature class regardless of the spatial reference.

Outcomes