0

I have a list of raster files in TIFF format and I want to convert that TIFF to points using raster to point conversion (tool of ArcMap). This tool will convert the raster into a point shapefile. I tried the following code but it did not go through.

import arcpy
from arcpy import env


env.workspace = "E:/testextract"
outpoint = "E:/testextract/hh"
field = "VALUE"
Rasters = arcpy.ListRasters ()
for inRaster in Rasters:
    outpoint = outpoint + "\\"+ inRaster
    arcpy.RasterToPoint_Conversion (inRaster, outpoint, field)

Can anybody help on this?

  • 1
    any error messages? That would help.. you are specifying outpoint = "E:/testextract/hh" but not arcpy.env.overwriteoutput... so perhaps the error is 'output already exists'. Can you explain more about what you're trying to achieve? Do you want all the points in the same feature class or each one into a new shapefile in an out folder etc. – Michael Stimson Apr 21 '15 at 4:59
1

The error is occurring because you have faulty logic in the way you are building the output name. You keep concatenating to an existing string rather than resetting it.

Lets say you have 3 rasters r1,r2,r3. You initially set outpoint = "E:/testextract/hh"

The first iteration of your loop you create E:/testextract/hh\r1

second iteration would create E:/testextract/hh\r1\r2 and third iteration would be E:/testextract/hh\r1\r2\r3.

So you need to tweak your code to something like:

outpoint = r"E:\testextract\hh\"+ inRaster

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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