Python Scripting

Python scripting is a type of computer coding method that is used my geospatialists in conjunction with the acpy library for ArcGIS to streamline processes. It may be difficult to learn, however, it is one of the easier coding languages for beginners and its capabilities of running tools and organizing or searching through files by use of certain commands makes processing data in ArcGIS easier and more time-efficient.

October 23, 2015

Python Scripting Activity 1: Loading Rasters Into a Geodatabase

This python script was created to project rasters from the Data Gathering lab into a common coordinate system matching that of the Trempealeau County Geodatabase, clip rasters to the Trempealeau County border, and to extract and save output rasters into a new geodatabase (Fig. 1). The rasters that resulted from this script will later be used to investigate impacts of the sand frac mining in Tremealeau County and to create suitability and risk models.


Fig. 1: Python script to project, clip, and load rasters into a geodatabase for the Data Gathering lab.

November 13, 2015

Python Scripting Activity II: Network Analysis Data Preparation

This python script was used to prepare the data for our upcoming network analysis lab. In the script, I defined the variables to be used in the script, create SQL statements to select for mines that had active status, had the word "mine" in the facility type attribute, and did not have the word "rail in the facility type. I then made feature layers from these selections. I then selected mines from Wisconsin by using intersect in PyScripter, selected Wisconsin mines within 1.5km of a rail line, and saved the output. 
At first, my script was not working and I had reworked the script in such a way that yielded 85 mines where we were supposed to have around 45 in the output. Upon talking with the professor, the problem was merely an uncapitalized letter and a couple of missed spaces in the SQL statements. 

Fig. 1: Python script to select mines that are active, have "Mine" in the facility type attribute, and do not have "rail" in the facility type, then to create feature layers from these selections, intersect with Wisconsin boundary, select within 1.5 km from a rail, and save the output.

The result of the final script had a total of 44 mines in the output. This is approximately the number expected from the output. The resulting mines were placed on a map of Wisconsin and all seem to correct in location from rails and within the border of Wisconsin (Fig. 2) The attribute table shows all mines follow the SQL statement selections as well.
Fig. 2: Result of python script containing mines at appropriate distance from railways, within the state of Wisconsin, and attributes that follow the SQL statements in the script.


November 14, 2015

Python Script III: Building A Weighted Risk Model

This python script was used to build a weighted risk model in conjunction with activity 8: Raster Modeling. The script uses spatial layers created in activity 8 which are set to variables and one variable is weighted as more important than the other variables to create this weighted risk model. I chose perennial streams as the most important, or most vulnerable, environmental risk variable that can be impacted by frac sand mines (Fig. 1). I chose this variable because perennial streams that have a constant flow and presence in the channel have the ability to carry pollutants to other bodies of water. The streambeds and surrounding areas of land will also be contaminated by any frac sand mine pollutants. This can include an overabundance of dust and other particles set loose by the fracking process. 

Fig. 1: Python Script used to create a weighted risk model with perennial streams weighed as more important, or more vulnerable to frac sand mines. 

The resulting weighted environmental risk model shows the areas of potentially high to low environmental and community risk due to possible future frac sand mines in Trempealeau County (Fig. 2). The model has weighed perennial streams as more vulnerable to the mines and areas near perennial streams consequently show higher potential impact. It is advisable to build any potential future frac sand mines in areas shown to have lower potential risk.





No comments:

Post a Comment