AnsweredAssumed Answered

Raster to polygon script loop failing!! error 99999!

Question asked by aliceduffesriuk-esridist Employee on Dec 7, 2010
Latest reply on Jan 5, 2011 by vsfoote

I am have already posted this in the general forum but i managed to solve that issue and now i have a new one!

I keep getting an error 99999 error message at line 37!
( gp.RasterToPolygon_conversion(INPUT_RASTER, Output_polygon_features, "SIMPLIFY", "VALUE") )
I am trying to make a script which selects every .png file in a folder beginning with the letters "LG". I then want the scipt create a shapefile, replacing the "LG" with "SH", and then i want the script to buffer that shapefile and rename the buffer with the first 2 letters being "SB"!

Can anyone see why this isnt working? I am very, very new to this and have been staring at this script pulling out my hair for days!! :o

Here is the script:

# ---------------------------------------------------------------------------
# Created on: Wed Dec 01 2010 12:20:48 PM
#   (generated by ArcGIS/ModelBuilder)
# Usage: RASTER2POLYGON <INPUT_RASTER> <Output_polygon_features> <Raster_Buffer_shp>
# ---------------------------------------------------------------------------

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx")
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx")

# Script arguments...

folder = "D:\\J04-0083\\IMAGEFILES"
for root, dirs, filenames in os.walk(folder): # returms root, dirs, and files
    for filename in filenames:
        filename_split = os.path.splitext(filename) # filename and extensionname (extension in [1])
        filename_zero = filename_split[0]

            first_2_letters = filename_zero[0] + filename_zero[1]
            first_2_letters = "XX"

        if first_2_letters == "LG":
            Output_polygon_features = "D:\\J04-0083\\ShapeFiles.gdb\\" + "SH_" + filename + ".shp"

            # Process: Raster to Polygon...

            INPUT_RASTER = os.path.join(root + "\\" + filename_zero + ".png")
            gp.RasterToPolygon_conversion(INPUT_RASTER, Output_polygon_features, "SIMPLIFY", "VALUE") 

            Distance__value_or_field_ = "5 Meters"
            Raster_Buffer_shp = "SB_" + filename + ".shp"

            # Process: Buffer...
            gp.Buffer_analysis(Output_polygon_features, Raster_Buffer_shp, Distance__value_or_field_, "FULL", "ROUND", "NONE", "")