Friday, March 11, 2016

Python Scripts

Background

Python is a computer language that is used to automate computing tasks, which can help make work easier, more accurate, and faster. It is an important skill to develop as a GIS analyst to learn how to write script. Python is great for beginners and the syntax is simple to understand compared to other scripting programs.

Demo 1

Goals: The goals of python demo 1 included learning about GIS automation and its purpose, connecting to different servers in order to access and work with its data, learning about Python and what a Python Snippet is, and learning how to enter code and perform geoprocessing tasks in PyScripter.

Results: See figure 1 below

Figure 1: Python demo 1 script
Demo 2

Goals: The goals of demo 2 were to expand on what we learned in demo 1 by learning how to edit a script template, import system modules, setting up a script and a tool with parameters, and printing a statement.

Results: See figure 2 below

Figure 2: Python demo 2 script

Demo 3

Goals: In continuation of what we learned in demos 1 and 2, in demo 3 we learned how to set a variable in a script. A variable in this case represents an object or a value that the computer will store to be used later on.

Results: See figure 3 below

Figure 3; Python demo 3 script

Exercise 5: Sand Mining Suitability Project

Goal: The goal of this section of the project was to write a Python script that would project, clip, and load rasters into a geodatabase that were downloaded from the internet. The rasters include land cover types, elevation, and crop land cover.

Results: See figure 4 below

Figure 4: Python Exercise 5 script

Exercise 7: Network Analysis Part 1 - Data Preparation 

Goal: The goal of this part of the exercise was to write a script to select the mines that would be used in our analysis later on. The script would use queries and select by location to find the mines that met the following:

  • The mine is active
  • The mine must not have a rail loading station on-site
  • The mine is farther than 1.5 kilometers from a rail line
Results: See figure 5 below

Figure 5: Exercise 7 Part 1 Python script

No comments:

Post a Comment