Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Valid input for ArcPy raster to polygon in 10.1?

$
0
0

I’m experiencing some strange problems with this code starting from files with *.tif.tif to what seems should be *.tif.tif.shp according to the code. The code is not working because of the arcpy.RasterToPolygon_conversion Error 010157: Unable to open feature class. File name snowdepthN0001.tif.tif. Though the code fails, I get a single file in my output folder called snowdepthn0001.tif.shp (not sure why it’s making the n lower case). This is not the extension that I was expecting, and why would only this file turn up when there are 90 files in the input folder? I have everything set-up to preference according to http://resources.arcgis.com/en/help/main/10.1/index.html#//001200000008000000 but it seems there may be an extension problem. Thanks for any ideas. I’ve tried both inside and outside of an ArcMap session.

import arcpy, os
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")

env.workspace = r"C:VMsharedsmall_example_valley8SDpartINTRaster"
outFolder = r"C:VMsharedsmall_example_valley8SDpartINTshapefile"

for rasterFile in arcpy.ListRasters("*.tif"):
    oName, oExt = os.path.splitext(rasterFile + ".tif")
    outShape = os.path.join(outFolder, oName + ".shp")  
    arcpy.RasterToPolygon_conversion(rasterFile,outShape,"NO_SIMPLIFY","Value")

print "done"

#Executing: RasterToPolygon C:VMsharedsmall_example_valley8SDpartINTRastersnowdepthN0001.tif.tif C:VMsharedsmall_example_valley8SDpartINTshapefilesnowdepthN0001.tif.tif.shp NO_SIMPLIFY Value
#Start Time: Sat May 16 15:12:54 2015
#ERROR 010157: Unable to open feature class C:VMsharedsmall_example_valley8SDpartINTshapefilesnowdepthN0001.tif.tif.
#Failed to execute (RasterToPolygon).

Viewing all articles
Browse latest Browse all 767

Trending Articles