Last week we worked with Vector features and this week's focus was working with Rasters.
Our text discussed how to list rasters and describe properties of raster features. We learned that the arcpy raster class enables us to create a raster object by referencing an existing raster on disk or using map algebra statements. The raster object output is temporary. If the user desires to save the an output raster they must use the .save() method to make the raster object permanent. Using the Spatial Analyst module the user has access to geoprocessing tools and map algebra operators. The four categories of map algebraic operators are: Arithmetic, Bitwise, Boolean, and Relational.
Working with feature classes (landcover and elevation) in a provided geodatabase we were tasked with creating a new raster that included only forested lands with slopes between 5-20 degrees and aspects of 150-270 degrees. After importing necessary modules and setting the workspace environment and overwriteOutput option we had to create an "if" conditional statement to check for the spatial analyst license. We then had to reclassify the "landcover" feature class to show only forested lands. I had to take time to visually see and understand the remap and reclassify functions. I displayed the landcover feature class in ArcMap and looked at its attribute table. The reclassified landcover feature was a temporary raster that was assigned a name.
Next, using the Slope and Aspect tools we created two more temporary rasters. Using relational map algebra operators I created four statements to meet the required slope and aspect conditions.
Finally, I used the boolean "and" operator to combine the reclassified landcover raster with the conditional slope and aspect rasters to create a new raster. I chose to create a new geodatabase and save my new raster as a feature class of this geodatabase.
I actually found an error in my code writing this blog. I realized I used the wrong relational operators for my aspect statements and had to rerun the script. The most difficult part of this lab was taking time to really understand the classes/tools/functions and what output they created. Being able to visually see the feature classes in ArcMap helped, but even that did not keep me from making my mistake. Hopefully, in a real world scenario there would be more than one set of eyes on a project and I would be more familiar with the data being used.
Shown below is a screen shot of my final raster feature and the flowchart for the Python script.
Shown below is a screen shot of my final raster feature and the flowchart for the Python script.
Module 9 Flow Chart for Script |
No comments:
Post a Comment