Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As part of a tool, I’m trying to convert a feature class to a raster based on attribute field values. I have accomplished this conversion using IRasterConvertHelper, but this is done without specifying an attribute field. So I then was able to do the conversion using the IGeoProcessor to execute ConversionTools.FeatureToRaster , but was only able to use numeric fields (i.e., tool didn’t work when a text field was selected).

Going another route, I tried dissolving the feature class based on a selected attribute field using IBasicGeoprocessor and Dissolve, but this fails with: {System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component. (thanks ESRI, lots of help!)

Does anyone have any idea on how to accomplish the same thing as the ArcToolbox Conversion Tools Feature to Raster tool and convert a feature class into a raster based on an attribute field?

share|improve this question
Using IRasterConvertHelper and its ToRaster1 function, I have been able to complete this task using a numeric field (integer and decimal). Unfortunately the code doesn’t want to work with a text field and returns the error message: Item width must be greater than 0. Any thoughts? – Luther Quinn May 16 '11 at 14:10
I've never heard of a raster whose values are strings. Instead, I think summarizing the string values into an integer code, then using the codes to apply labels to an IRasterUniqueValueRenderer – Kirk Kuykendall May 17 '11 at 2:47
  1. For each feature in FeatureClass, add the value from the specified field to an IDictionary; it may help to create another collection to hold the records in reverse order, so both keys and values are accessible (IDictionary)
  2. IFeatureClassDecscriptor.Create ( FeatureClass as IGeoDataset, ……)
  3. IRaster = IRasterConvertHelper.ToRaster1(FeatureClassDescriptor as IGeoDataset, ……)
  4. IRasterDataset = IConversionOp.ToRasterDataset (IGeoDataset, format, out_workspace, …..)
  5. IRaster2 = IRasterDataset.CreateDefaultRaster()
  6. ITable = IRaster2. AttribuateTable
  7. ITable.AddField(new_IField)
  8. ICursor = ITable.Search
  9. IRow = pCursor.NextRow
  10. IRow.set_Value(….)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.