Posts

Showing posts with the label GIS5103

GIS5103 Module 6: Working with Geometries

Image
     In this week’s GIS Programming lab, we focused on creating a search cursor to iterate over shapefile geometries and demonstrating the ability to write vertices of a geometry to a text file. Ultimately, we needed to create a script that successfully wrote (into a text file, such as in Notepad++) with specific vertex/point information: Feature OID Vertex ID X-coordinate Y-coordinate Name of river feature The below screenshot is a snippet of the completed, successful script outcome. From left to right, items are: OID, vertex ID, X-coordinate, Y-coordinate, and name of feature. See below flowchart providing a logical flow of script created:

GIS5103 Module 5: Exploring & Manipulating Data

Image
     This week’s lab in GIS Programming focused on exploring and manipulating data. We wrote a script that created a new file geodatabase (fGDB), copied relevant data into the created fGDB, and populated a dictionary with names and populations of the County Seats within New Mexico, USA. To view the thought process in creating this script, see below flowchart:   Flowchart documenting process of creating requested script outcome To view the results indicating the successful run of the script, see below screenshots:        The main problem I had in this lab was finding an effective way to populate each item to the created dictionary.   After several trials of code, I went back and used the Search Cursor for loop with the same parameters to only select the correct key and value. I was setting my key to ‘County Seats’ when it should have been “NAME”. After figuring that out and trying more coding that was more along the lines of what was de...

GIS5103 Module 4: Geoprocessing

Image
     This week's lab in GIS Programming gave us insight on geoprocessing operations. We focused on creating and modifying scripts, using ModelBuilder within ArcGIS Pro to create scripts, and understanding toolboxes (in ArcGIS Pro).  Successfully ran script results 1          Adding XY Coordinates: Following the Exercise instructions helped guide me throughout this lab. I understood if I were to run something in Python that may include arcpy, I would need to first import arcpy – this isn’t necessarily needed when working in ArcGIS Pro Notebooks as ArcGIS is already aware of arcpy. I wanted to be able to import my environment workspace, so I needed to communicate effectively in writing the location of the data. Because we were tasked to focus on the hospitals shapefile, I made that the in_features . I then used the arcpy.management.AddXY(in_features) code to apply XY coordinates to hospitals, and created a print code that printe...

GIS5103 Module 3: Debugging and Error Handling

Image
     Module 3 in GIS Programming focused on debugging and handling errors within scripting. We used our previously gathered knowledge in this course to supplement the objective of this lab. We were given (3) separate scripts to determine what is the error in each, how to fix the errors, and we were also given the opportunity to use a try-except statement to allow for a script to run with an error. It might seem like you would want all scripts not to have error -- sometimes we would want to have the script run with that error as an exception, but print the resulting error statement that arises.  Our results are as follows:  Script 1:  Script 1 Results Script 2: Script 2 Results Script 3: Script 3 Results In Script 3, we utilized the try-except statement to indicate the error in Part A of this task - see below for a flowchart of the implemented statement:  Try-except statement flowchart Part A in Script 3 wanted us to be able to use the try-except statem...

GIS5103 Module 2: Python Fundamentals

Image
               This week’s lab in GIS Programming focused on the fundamentals of Python. We worked with string variables, how to include comments in script in a way that wouldn’t impact the script outcome, how to iterate variables within loops to control script workflow, as well as created loops and conditional statements. Part 1 of lab included being able to assign a variable as a string, splitting that string into a list, and indexing to pluck the last string list item as the output when ran. For this part, we assigned our full name as the variable and indexed the script to print our last name. Part 2 of lab consisted of looking at prewritten script for a dice game and trying to determine the (2) errors that prevented the script from running without error. Part 3 of lab asked that we create a loop that will add (20) random numbers between (0) and (10) to a list. We needed to utilize a while loop that appended a randomly generated number...

GIS5103 Module 1: Python Environments & Flowcharts

Image
     The first week of GIS Programming touched on a brief introduction to the Python programming language and how to think algorithmically with the use of flowcharts. A few notes of interest:  General Command Prompt not the same as Python Command Prompt “dir” – basically tells computer/Command Prompt “What is in the directory?” Python is an interpretive language, NOT a compiled language IDLE = Integrated Development Learning Environment – book refers to as Integrated DeveLopment Environment, however Usually do script in file and send (“Run”) to do interpretation Workflow = flowchart Python in ArcGIS Pro TWO ways to launch Python in ArcGIS – (either will open new Notebook)   Method 1 : Insert Tab -> “New Notebook” (in Project group) Method 2 : Analysis Tab -> “Python” Notebook consists of cells To run CURRENT cell being written in, hit Ctrl + Enter OR click “Run” We used  https://app.diagrams.net  to create a flowchart u...