Friday, March 18, 2016

Python Coding

Python

Python is an extensive computer coding language used in several programming software. In ArcGIS, python is used to organize and conduct geoprocessing. Using python allows for faster and more efficient geoprocessing procedures. 

Purpose

The purpose of this blog is to demonstrate the various python coding skills learned throughout the semester in GIS II. These python scripts will be used to work toward the semester long project regarding frac sand mining and the impacts it has on Trempealeau County, Wisconsin.

Python Script #1:
PyScipter, a python software, was used for this script. PyScripter allows for better organization compared to the python window found in ArcGIS. This python script shows the process of gathering 3 raster files (downloaded in part 1 of exercise 3 from various sources) and putting them into a geodatabase. The geodatabase is for data within Trempealeau County and is title "TMP.gdb". Once the files were ready to be put into the geodatabase, I began using pyscripter. To begin, I had to set the workspace environment and several variables to be used throughout the script. Within the script, I had to project the rasters by adding a file from a dataset in the geodatabase already. By doing this, the raster in question will adopt this dataset's projection. Next, I had to clip (extract by mask) the files with the Trempealeau county boundary. This allows for faster and more efficient geoprocessing. Finally, I moved the raster files into the geodatabase to be used in the remainder of the project.

Python Script #2:
This python script was created to prepare the data for network analysis in Exercise 7. Our goal was to determine the impact that transporting frac sand has on roads within the local area of the specific mine. The following perameters were set to calculate this impact.

  • The mine must be active.
  • The mine must not also have a rail loading station on-site. 
  • Mine must not be within 1.5 kilometers of a railroad
To begin, I set up the script and set the work space environment. I then set up the variables that would be used throughout the script. Using these variables, I wrote  several Structured Query Language statements to ensure the parameters were met. I then ran these statements to narrow down the amount of mines to be used. From here, I selected all of the mines within 1.5 km of the railroads and removed them from the selection. This left me with all of the mines that can be used later on in the exercise to conduct network analysis.



No comments:

Post a Comment