Module 9 - Working with Rasters

This week we learned how to work with raster data using Python. We explored two important functions: ListRasters (which returns a Python list of rasters in a workspace), and Describe (which returns property information of a specified data element). There are 3 different raster data elements: raster dataset, raster band, and raster catalog. We also worked with raster objects. Did you know that raster objects only have one method? It's the save method; and it used to make a raster permanent. We also worked with the ArcPy Spatial Analyst module, or arcpy.sa, which allows us to access all of the raster geoprocessing tools in the Spatial Analyst Extension toolbox. The arcpy.sa module is very useful because it also allows us to integrate "map algebra" into the Python environment. We also practiced using classes of the arcpy.sa module, specifically RemapValueRemapRange, and Reclassify.

For our lab assignment, we were tasked to write a Python script that creates a raster output meeting the following criteria: forest landcover (classifications 41, 42, and 43), a "slope" between 5-20 degrees, and an "aspect" between 150-270 degrees. To successfully create this script we had to import all the necessary modules and classes; write a conditional if/else statement checking for the availability of the Spatial Analyst Extension; reclassify the landcover map to only show forested land (this was achieved by using the .RemapValue() and .Reclassify() functions); create variables to prepare for the "slope" and "aspect" calculations (this was achieved using the .Raster(), .Slope(), and .Aspect() functions); using map algebra (specifically the Boolean And) to combine all temporary variables; and finally using the .save() method to save our final output. Below is a screenshot of my script results in the PythonWin Interactive Window.


And below is a screenshot of the raster output created by the Python script, depicted in ArcMap. As you can see, areas that meet the aforementioned criteria (parameters) are given a value of 1, and all other areas have a value of 0.

Comments