Python Blog
In this blog I will keep an updated page showing all of the python that I use throughout the spring semester in GIS 2 Geog 337.
The first python script that I created was for our Exercise 5 assignment. The purpose of the script was to take the rasters that we downloaded from an internet source and put them into a geodatabase. We had three rasters and all of them came from different sources. This means that they were all in different coordinate systems. Because of this the script needed to project each raster. The next step was to clip the raster. We had a study area of Trempealeau County in Wisconsin so we clipped each raster to the county boundary shape. The last step was to load the clipped and projected raster into the geodatabase. Below is a screenshot of the final script that successfully ran and accomplished all of the above tasks.
Exercise 7 Python Script
The purpose of this script was to prepare our data for part two of exercise 7. The goal of this script was to select all of the mines that will be used in network analysis in part 2. To set up the data we needed to locate the mines that meet the following criteria:
- The mine must be active
- The mine must not also have a rail loading station on-site.
- The mine must not be located within 1.5 km of a railroad
In order to find this data using Python, it was necesary to set up SQL statements that would select the mines by being active and not having a railroad on site. The next major step was then to select these mines by location to make sure that they were not within 1.5 km of a rail road. My end results came up with a total of 44 mines that were not within 1.5 km of a railroad. Once the script ran, I went into ArcMap to explore the data to see if the script ran correctly. I created a buffer around the new output class to make sure that it truly wasn't within 1.5 km. The data appeared to be correct. Below is a screen shot of the script that I wrote to complete the tasks.
Exercise 8 Python Script
In exercise 8, the final part was to use python to create a weighted index on the environmental impacts. I decided that using residential areas as the weighted feature was the most important. That would be something that would be hard for the mine to get around so I made it more important. This was a relatively quick python script where I just set variables to all of the rasters used in the model. I then took the residential area and multiplied it by 1.5 in raster calculator in order to make it more important. THe last step was to take the weighted value and add it to all of the other rasters in raster calculator. The result was a weighted index. The python script is located below.



