Using Topo to Raster in Python???

1051
2
02-20-2011 04:05 AM
CharlesGant
New Contributor III
I posted this in the Python section as well since I did not really know where to post since it was both Python and Geoprocessing. 

I'm new to exporting a model to python script. I'm trying to automate the generation of maps. I have a toolbox with a tool in it called PrecipMap. I need to be able to run that tool automatically. I exported the script and tried to run. I get this error.

File "R:\PrecipMap\PrecipMapping.py", line 44, in <module>
arcpy.gp.TopoToRaster_sa("R:\\PrecipMap\\DailyPrec ip.shp pcpn PointElevation
", TopoToR_shp2, "0.003", "R:\\Shapefiles\\Other Shapefiles\\MEGCWA.shp", "20",
"", "", "ENFORCE", "CONTOUR", "40", "", "1", "0", "", "", Output_stream_polyline
_features, Output_remaining_sink_point_features, Output_diagnostic_file, Output_
parameter_file)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing \_base.py",
line 474, in <lambda>
return lambda *args: val(*gp_fixargs(args))
arcgisscripting.ExecuteError: ERROR 000622: Failed to execute (Topo to Raster).
Parameters are not valid.
ERROR 000628: Cannot set input into parameter extent.

So it says the parameters are not set. This all works just fine in Model Builder. Can someone help me? I have tried to set the parameters but I'm not really sure what I'm doing or what the parameters even are. Everything in the topo to raster tool that is not "optional" is defined. Any help would be greatly appreciated.



Also, here is the exported code:

# ---------------------------------------------------------------------------
# sample.py
# Created on: 2011-02-19 11:28:49.00000
# (generated by ArcGIS/ModelBuilder)
# Description:
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")


# Local variables:
MEG_counties_shp__2_ = "R:\\Shapefiles\\Other Shapefiles\\MEG_counties.shp"
rr3precip_csv = "W:\\gistemp\\rr3precip.csv"
DailyPrecip_layer = "DailyPrecip_layer"
DailyPrecip_shp = "R:\\PrecipMap\\DailyPrecip.shp"
TopoToR_shp2 = "R:\\ArcGIS\\Default.gdb\\TopoToR_shp2"
DailyPrecip_img = "R:\\PrecipMap\\DailyPrecip.img"
DailyPrecip100_img = "R:\\PrecipMap\\DailyPrecip100.img"
DailyPrec100 = "R:\\PrecipMap\\DailyPrec100"
DailyPrecipcontour_shp = "R:\\PrecipMap\\DailyPrecipcontour.shp"
Output_stream_polyline_features = ""
Output_remaining_sink_point_features = ""
Output_diagnostic_file = ""
Output_parameter_file = ""

# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(rr3precip_csv, "lon", "lat", DailyPrecip_layer, "", "")
print 'Make XY Event Layer Done'
# Process: Copy Features
arcpy.CopyFeatures_management(DailyPrecip_layer, DailyPrecip_shp, "", "0", "0", "0")
print 'Copy Features Done'
# Process: Topo to Raster
arcpy.gp.TopoToRaster_sa("R:\\PrecipMap\\DailyPrec ip.shp pcpn PointElevation", TopoToR_shp2, "0.003", "R:\\Shapefiles\\Other Shapefiles\\MEGCWA.shp", "20", "", "", "ENFORCE", "CONTOUR", "40", "", "1", "0", "", "", Output_stream_polyline_features, Output_remaining_sink_point_features, Output_diagnostic_file, Output_parameter_file)
print 'Topo To Raster Done'
# Process: Clip
arcpy.Clip_management(TopoToR_shp2, "-91.407437 33.650117 -87.970738 36.630955", DailyPrecip_img, MEG_counties_shp__2_, "", "ClippingGeometry")
print 'Clip Done'
# Process: Single Output Map Algebra
arcpy.gp.SingleOutputMapAlgebra_sa("100 * [DailyPrecip.img] ", DailyPrecip100_img, "R:\\PrecipMap\\DailyPrecip.img")
print 'Map Algebra Done'
# Process: Int
arcpy.gp.Int_sa(DailyPrecip100_img, DailyPrec100)
print 'Int Done'
# Process: Raster to Polygon
arcpy.RasterToPolygon_conversion(DailyPrec100, DailyPrecipcontour_shp, "SIMPLIFY", "VALUE")
print 'Raster To Polygon'

I added the "print" commands in there so I could track where the errors where happening.
0 Kudos
2 Replies
CharlesGant
New Contributor III
Fixed.  I figured it out, finally.
0 Kudos
BartKowalski
New Contributor
Charles, care to give a bit more details for those of us who are still struggling with this error.

Thanks,

Bart
0 Kudos