I am running a lengthy script to post-process raster channel paths into polylines so I can measure their length using Add Geometry. Script runs well until I go to convert the rasters to lines using the Raster to Polyline tool in arcpy, shapefiles are output when the error is overwritten but attribute tables are empty and they can't be drawn in arcmap. Input Raster is integer type, data has coordinate system, channel paths are 1's and all other cells are nodata. Shapefiles are missing the optional .sbn and .sbx supporting files.
I have tried running the Raster To Polyline tool from within ArcMap and it works fine.
Workarounds accepted. Script is long so a snippet where failure occurs is below.
arcpy.env.workspace = CPC_rename #sets workspace
CPC_lines = CPC_rename + '\\' + folder7 # sets output workspace
rasters = arcpy.ListRasters('*', 'TIF') # Lists Rasters
for x in range(0, len(rasters)): # set up a for loop
linesOut = os.path.join(CPC_lines) + '\\' + rasters[x] + '.shp' # setup the output file
arcpy.SetSeverityLevel(0) # override the 999999 error so it runs all the way through
arcpy.RasterToPolyline_conversion(rasters[x], linesOut , "ZERO", 0, "NO_SIMPLIFY", "Value") # apply the arcpy tool
print 'something' # print something to confirm its running
CPC_lines = CPC_rename + '\\' + folder7
toos.path.join(CPC_rename, folder7)
. What gets printed out withprint linesOut
Print linesOut
was giving me a "raster.tif.shp", which I was having trouble cleaning up, but Michael's solution helped me do that. Include your solutions as an answer and I will happily upvote them and accept as answers.