Select to view content in your preferred language

Ascii to Raster Parameters are not valid

2613
3
11-06-2011 10:55 PM
tomwaddington
Emerging Contributor
This is a simple script that I have used many times before, the only difference this time is that I am not using the exact directory. But instead a workspace + "" method so that the final script and be used on any computer (the workspace is initially defined at the beginning of the script). Here I the script, I have looked it over several times and so have my colleges this is only one part of the main script but there are so many errors with it even though it has previously work so trying to debug them one at a time.

Can some one please explain why when I run the Ascii to raster conversion the 'Parameters are not valid'? (This happens on the first conversion attempt)

Here is the script that i have been using.

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

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

#Check out any necessary licenses
gp.CheckOutExtension("spatial")
# Check out ArcGIS 3D Analyst extension license
gp.CheckOutExtension("3d")
gp.CheckOutExtension("arc")

gp.overwriteoutput = 1

# Load required toolboxes...
gp.AddToolbox("C:\Program Files\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes/Conversion Tools.tbx")
gp.AddToolbox("C:\Program Files\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes/3D Analyst Tools.tbx")
gp.AddToolbox("C:\Program Files\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes/Spatial Analyst Tools.tbx")
gp.AddToolbox("C:\Program Files\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes/Data Management Tools.tbx")
gp.AddToolbox("C:\Program Files\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes/Spatial Statistics Tools.tbx")

             
            

#ASCIIToRaster
workspace = "H:\tom\old_code\data/"
ASCII_file = "H:\tom\old_code\data/dhm25.asc" #sys.argv[1]
ASCIIFOR_file = "H:\tom\old_code\data/forest.asc" #sys.argv[2]
Output_DEM_raster = workspace + "dem"
Resample_raster = workspace + "dem_resample"
Resample_for = workspace + "for_resample"


# Process: ASCIIToRaster_conversion
print gp.GetMessages()
gp.ASCIIToRaster_conversion(ASCII_file, Output_DEM_raster, "FLOAT")
gp.ASCIIToRaster_conversion(ASCIIFOR_file, workspace + "forest", "FLOAT")
Tags (2)
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus
in python, you use double-backslashes, raw formatting or forward slashes for all paths, ie
"c:\\temp"
r"c:\temp"
"c:/temp"
0 Kudos
tomwaddington
Emerging Contributor
Thank you that solved the problem right away. You couldnt possibly shed a light on to this issue too could you?


# Local variables...
OutCurvatureRaster = workspace +  "curv"
InZFactor = "1.0"
OutProfileCurveRaster = workspace +  "curv_profile"
OutPlanCurveRaster = workspace +  "curv_plan"

# Process: Curvature...
gp.Curvature_3d(Resample_raster, OutCurvatureRaster, InZFactor, OutProfileCurveRaster, OutPlanCurveRaster)
# we do not need two of the rasters...delete them
gp.delete_management(OutCurvatureRaster)
gp.delete_management(OutProfileCurveRaster)
# Process: MapAlgebra, classification of plan curvature...
gp.MultiOutputMapAlgebra_sa(workspace + "curv_plan_1" = CON(workspace + curv_plan "> 3,3,0"))

The script section is taken from the next stage of the previous script but wont run because it keeps saying there is a syntax error in the final line shown. In particular this occurs and keeps highlighting " with in the condition string.
0 Kudos
DanPatterson_Retired
MVP Emeritus
CON(workspace + curv_plan "> 3,3,0"))
perhaps should be
Con(workspace + curv_plan " > 3",3,0))
but I don't have versions prior to 10.0 to check it on
0 Kudos