For this week's lab we worked with several Geoprocessing tools to manipulate a raster output to create areas with particular parameters for, slope & aspect. We created a script that would create a single raster image to highlight areas with the following characteristics:
- Forest landcover (classifications 41, 42 & 43)
- Slope between 5–20°
- Aspect between 150–270°
I took the data we had and wrote the basic parts to the script. I was able to import arcpy, and set the environment and enable overwrite. My challenge started when I had to create new rasters using the Spatial Analyst (arcpy.sa) module (ArcPy SA). After importing the Spatial Analyst module (from arcpy.sa import *) I had all the tools I needed to complete this lab, but somewhere I went left when I should have gone right, or something like that.
I established the code for the conditional loop to "CheckOutExtension("spatial") so that I could move on to create temporary rasters and then combine them to make the raster as defined by:
- Slope less than 20
- Slope greater than 5
- Aspect less than 270
- Aspect greater than 150
I had errors such as:
Traceback (most recent call last):
File "S:\GISProgramming\Module9\Scripts\Mod9_gilcastillo.py", line 47, in <module>
outraster.save("S:/GISProgramming/Module9/Data/Elevation.gdb/slope_per") #Results/slope_per")
RuntimeError: ERROR 010240: Could not save raster dataset to S:\GISProgramming\Module9\Data\Elevation.gdb\Slope_elevat4 with output format FGDBR.
And,
File "C:\GIS\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000860: Input raster: is not the type of Composite Geodataset, or does not exist.
Failed to execute (Slope).
Colorful, yes; helpful, not really. I tried several changes (sometimes many at the same time, but more often, small changes one at a time to format, and syntax using Debugger). One of the last changes I tried was to create a new "gdb". But not even this helped me correct the errors in my script so that it would progress to the end. Here's what my script finally produced:
No comments:
Post a Comment