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

I have a feature class with 5 lines in it, and need select each one and turn them into its own raster -- for example, line 1 is raster 1, line 2 is raster 2, etc. This is the python script:

import arcpy

SightLines = "C:\\temp\\SightLines.shp"

index = 0
rows = arcpy.SearchCursor(SightLines)
for row in rows:
    RasterFileName = "C:\\temp\\fakeData.gdb\\Raster" + str(index)
    arcpy.AddMessage("Raster File " + RasterFileName)
    arcpy.FeatureToRaster_conversion(row, "FID", RasterFileName, "1")
    arcpy.AddMessage(" >> MADE SUCCESSFULLY")
    index = index + 1

Unfortunately, this is throwing the following error at the FeatureToRaster_conversion step:

    raise e
RuntimeError: Object: Error in executing tool

I can't figure out what raise e is trying to tell me. What exactly is going wrong?

share|improve this question
up vote 2 down vote accepted

The "FeatureToRaster" conversion tool works on a feature class as a whole. You are passing it a row object, and this does not work. You would first need to extract each line as its own feature class, then convert that to a raster, then you can delete the temporary feature class.

share|improve this answer
OH. That explains quite a lot. Thanks :) – Erica May 20 '13 at 19:22

Instead of exporting a separate feature class per line, create a feature layer instead- This will speed things up since no new features need to be written to disk (feature layers are in memory).

share|improve this answer
Great tip. Thank you! – Erica May 21 '13 at 2:18

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.