3/17/14
Python Script 1 for Exercise 5: Sand Mine Suitability in Treampealeau County
Introduction: Utilizing Python Scripts
The objective for the following exercises is to gain experience utilizing python scripts to perform various tasks in GIS. Becoming acquainted with PyScripter and the coding language required to use PyScripter will be an important skill to have in the geospatial field. Utilizing python is a necessity to save time and increase efficiency which is extremely important when working with large quantities of data.
Results: Python Script
Below is the resulting python script from the Gathering Data: Sand Mine Suitability in Trempealeau County lab shown in notepad (Figure 1).
Figure 1. Python Script
The beginning of the script sets up the system modules and sets the environmental settings. The location of the three rasters that I was going to project and extract was set as the environment. Next, the rasters were looped into a different (new) folder using the listOfRasters function. The ProjectRaster_managment function was used to project the rasters in the desired coordinate system. Following this, the rasters were extracted to the boundary of the Trempealeau County. Last, the RasterToGeodatabase function was utilized to place the output rasters in the TMP (Trempealeau County) geodatabase. The outputs can be viewed at Sand Mine Suitability.
Python Script 2 for Exercise 7: Network Analysis
Below is the resulting python script from the network analysis portion of the ongoing sand mine suitability project (Figure 2).
Figure 2. Python script for Exercise 7: Network Analysis.
The script begins by setting up the different variables that will be used later on, and primarily consists the feature classes that will be created. Next, an SQL statement was created to query out the features that were to be used. In this case the query selected active mines, separated out facilities with the word mine in the title, and separated out facilities that did not have the word rail in the title.
After the query statements were generated, three separate layers were created from the query selections. The mines that were within the State of Wisconsin were then selected by using the "intersect" tool. Mines that were not in the State of Wisconsin were then removed. The last part of the script copied the selection so that a new feature class could be generated. In this case the feature class was called mines_norail_final (Fc8).
Python Script for Exercise 8: Raster Modeling
No comments:
Post a Comment