kevin.barnett

Converting Raster to ASCII errors

Discussion created by kevin.barnett on Jun 28, 2011
I'm writing a simple script that loops through and performs a series of geoprocessing tools.  I cannot get the Raster to ASCII conversion to work.  Errors range from "...does not have a file extension" to "...dataset does not exist".  Here is the code:

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

# Create the Geoprocessor object
try:

    gp = arcgisscripting.create()

                # Check out any necessary licenses

    gp.CheckOutExtension("spatial")

    gp.OverWriteOutput = 1

                # Load required toolboxes...

    gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx")

    gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")

    gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx")
except:

    gp.AddError(gp.GetMessages())

print "Starting"

# Load in DEM 

dem_BMWC = "C:\\WorkSpace\\Thesis\\GIS_Data\\NED\\BMWC\\Joined\\mosaic_utm_clip_Resample.img"

# Load in HUCs

hucs_Ahorn = "C:\\WorkSpace\\Thesis\\Output_Files\\ERS\\Ahorn\\Ahorn_HUCs.shp"

# Load in 2006 fuels data

fuels_BMWC = "C:\\WorkSpace\\Thesis\\GIS_Data\\Fuels_BMWC_2006\\fm40_2006"

# Load in burn severity data

severity_Ahorn = "C:\\WorkSpace\\Thesis\\GIS_Data\\BARC_FSGEODATA\\Ahorn\\Ouput_Files\\ahorn_reclass"

# Create feature layer from inputs

gp.MakeRasterLayer_management (dem_BMWC, "dem")
gp.MakeRasterLayer_management (fuels_BMWC, "fuels")
gp.MakeRasterLayer_management (severity_Ahorn, "severity")
gp.MakeFeatureLayer_management (hucs_Ahorn, "hucs")

# Create geodatabase for data storage
gp.CreateFileGDB_management("C:\\WorkSpace\\Thesis\\GeoWEPP\\", "Ahorn")

# Define workspace
gp.workspace = "C:\\Workspace\\Thesis\\GeoWEPP\\Ahorn.gdb"

# Looping through HUC layer
for i in range(0,8,1):
    expression = '"FID" = ' + str(i)

    new_huc = "huc_" + str(i)
    print "Creating " + new_huc
    gp.Select_analysis("hucs", new_huc, expression)

    new_ras = "ras_huc_" + str(i)
    print "Extracting dem for " + new_huc
    gp.ExtractByMask_sa("dem", new_huc, new_ras)

    new_ascii = "dem_ascii_" + str(i) + ".asc"
    print "Converting to ASCII " + new_ras
    gp.RasterToASCII_conversion(new_ras, new_ascii) 

Any thoughts??  Much appreciated!

- Kevin

Outcomes