Posts

Showing posts from June, 2023

GIS Programming Module 6: Working with Geometries

Image
The assignment for Module 6 involved reading the geometry of a feature class and writing the vertices of each feature on the screen and to a text file. This required the use of a search cursor to get all the features. Several loops were used to iterate through all the point objects. Both the screen and file outputs contain a line with the feature ID, vertex ID, X coordinate, Y coordinate, and the name of the river feature. Below is a screen shote of the screen output that was produced by the script. Screen of text file that was written by the script. I used IDLE to write the script for the module 6 assignment. A template for the script was provided that had comments that assisted in the placement of the code needed, including the loops that were required to iterate through the feature class. The assignment provided the input rivers shapefile which is a feature class that has all single part features. The script will not work for a feature class that had multipart features since we are

GIS Programming Module 5: Exploring & Manipulating Data

Image
The assignment for Module 5 involved working and manipulating data using an external Python script. The script creates a file geodatabase, copies existing shapefiles into the geodatabase, and uses cursors to view and print feature attributes. Part 1 of the script sets the current and output workspaces for the assignment. The current workspace contains all the shapefiles that were provided. The output workspace will contain all the results of the script including a copy of the shapefiles and the file geodatabase.   Below are the output messages printed for Part 1 of the script. Part 2 of the script lists all the shapefiles that are stored in the current workspace and copies them to the output file geodatabase. Below are the messages printed during Part 2 of the script. Part 3 of the script creates a Search Cursor containing all the features of the cities feature class that is stored in the output file geodatabase. The cursor only contains cities that are county seats and only the name

GIS Programming Module 4 – Geoprocessing

Image
Module 4 assignment involved using ArcGIS Modelbuilder and Python script that utilized multiple geoprocessing tools. Module 4 Assignment – Part A The first part of Module 4 assignment was to create a model using ModelBuilder that would create a polygon feature class containing prime farmlands inside a basin. Modelbuilder Model (Left) Image of basin boundary in blue overlayed on soils where red is non-prime farmland and green is suitable for farming. (Right) Image of clipped soils using basin as clip boundary. (Left) Image of selected of all soil polygons that are non-prime farmland. (Right) Image of soils with selected non-prime farmland erased. Module 4 Assignment – Part B The second part of Module 4 assignment was to write a script that uses the locations of hospitals and creates a 1000-meter buffer around the point location. I used ArcGIS Notebook to create and test the script. ·          I started by adding the standard comments section in the first cell of the notebook. ·     

GIS Programming Module 3 – Debugging and Error Handling

Image
Module 3 assignment dealt with debugging and removing errors in Python code. A Python error can be either a syntax error or a run-time error. Syntax errors are errors that are detected before the code is sent to the Python interpreter and prevent the code from running. Syntax errors will cause the code to abruptly stop. Syntax errors are generally caused by misspelling keywords, missing punctuation, or not indenting correctly. Run-time errors are logical errors in the code that do not prevent the code from running but produce incorrect results. Examples of run-time errors would be dividing by zero, undefined variables, trying to open a file that does not exist, and many others.  Run-time errors throw an exception that can be caught and handled using try-except statements. Script 1 of the assignment prints a list of all the fields in the parks shape file. The script contained one run-time error and one syntax error. The run-time error was a NameError caused by a variable name that wa