Tuesday, March 15, 2016

Python

Python Demonstrations

Python Demo:

The purpose of this first demonstration was to learn about the purpose of using python in relation to running functions in ArcMap and how to connect python to the geoprocessing environment. This demo was done entirely within ArcMap using the Python scripting window. This window allows for small amounts of code to be run directly in ArcMap for ease of use. Three actions were done using this method including two buffers and a clip to a provided geodatabase of "random" points in Michigan. One the three process had been run successfully the demo was complete. 

Since this particular demo was done in ArcMap and a text file was not saved a screenshot is provided below to show the recall of the projects run as they appeared as a Python script. 



Python Demo 2:

The second demonstration for Python scripting saw the introduction of PyScripter and ArcPy. Instead of needing to write the code within ArcMap, PyScripter enables the writer to write longer codes and check them as codes are written then the final code can be run and applied to ArcMap. This demo included the skills of editing a script template, setting up a script, and printing a statement. 

Below is a copied HTML text of the created script made in PyScripter and applied in ArcMap.

Python Demo 3:

In the third python demo more advanced PyScripter was practiced. Setting variables and running a tool to describe the data was put into application. This step delved deeper into how many different things PyScripter can actually do and how it can apply to spatial questions.

This is a text file of the run python code created in PyScripter:


Python for Mines in Ex 7:

This python script was constructed to run within a geodatabase with rail terminals, mines of any status, and rail lines. The goal was to use a script to find how many mines were not within 1.5 km of a rail line and still within Wisconsin. The number of mines that fit this criteria was found. The script ran and using a statement a print of how many features would be selected was had and the resulting layer contained 47 mines. Below is the script in a screenshot format.





No comments:

Post a Comment