Thursday, March 9, 2017

Python Scripting

What is Python?

Python is a programming language that is widely supported.  This language can be applied to data analysis, conversion, management, and map automation.  This free and open-source language has been accepted as the official scripting language for ArcGIS geoprocessing.  ESRI has fully embraced the Python scripting language.  Some advantages of Python include that it is easy to learn, it can be easily scaled to project size, it is applicable across platforms, it is embedded allowing ArcGIS to be scripted, it is stable, and can be utilized by a large community of users.

Why learn Python?

Python is a well accepted scripting language that is widely applicable.  If using ArcGIS in the future, it is important to be familiar with Python scripting, as it is an important skill to have that increases productivity.

Scripts

Lab 2: Gathering Data for Sand Mining Suitability Project 

Python script written to project, clip, and load all of the data for the project into a geodatabase.

Figure 1. Screenshot of script written in Pyscripter.

Figure 2. Screenshot of results of script in Pyscripter.  The script was successful.

Lab 7: Network Analysis

Python script written to select only active mines that do not have a rail loading station on site and are not within a 1.5 kilometer distance of a railroad.  This project aims to calculate the impact of trucking sand from mines to rail terminals on local roads, if a mine site uses a railroad for transportation, then it is not having an impact on the damage to roads because it does not use trucks.  

Figure 3. Screenshot of script written in Pyscripter. 

Figure 4. Screenshot of results in Pyscripter.  The script ran successfully. 

Lab 8: Raster Modeling

Python script written to to generate a weighted index model for the sand mining risk model that was created in Lab 8.  In this script raster math was done, and the factor of residential was seen as the most important factor so it was weighted by a factor of 1.5 when added to the other factors.  Residential was selected as the most important factor because residential represents the rankings for the land areas closest to residential areas as highest risk and the areas farther away as the lowest risk.  This is important for managing the impact of the noise shed created by the mining operation.  Keeping the locals happy is very important in conducting a mining operation, so making sure the mines were far enough away from residential areas was weighted as more important than the other factors.  The raster math conducted added all of the raster factors, streams, farmland, schools, wells, and the weighted residential together to conduct the risk model of the ranked rasters.  The locations with the highest values are the most at risk and the locations with the lowest values are of the least risk.  This script runs much like a Raster Calculator tool would in ArcMap.          

Figure 5. Screenshot of script written in Pyscripter.

Figure 6. Screenshot of results in Pyscripter.  This script ran successfully. 


Sources

ArcGIS Help 10.2, 10.2.1, and 10.2. (n.d.). Retrieved March 09, 2017, from http://resources.arcgis.com/en/help/main/10.2/index.html#//002z00000001000000