Posts

Showing posts with the label GIS Programming

M6 - Geometries

Image
Completed TXT file  Description of Screenshot In the screenshot, you can see the TXT file, which includes: Feature OID Vertex ID X coordinate Y coordinate Name of the river feature The python script created the TXT file, writes to the TXT file point data for all vertices of the "rivers.shp" with all of the above information. 

M5 - Exploring & Manipulating Spatial Data using Python

Image
 Screenshots of Script Results Description of Script The script successfully managed geospatial data in ArcGIS by creating a file geodatabase, copying feature classes, and extracting specific information about 'County Seat' cities. Excluding those with unknown population data, the final output is a populated dictionary containing the names and populations of these cities. The results displayed in the screenshot confirm the accurate execution of the script and the correct manipulation of the data. Flowchart of Script

M4 - Geoprocessing

Image
Successful Screenshot of Results   Discussion of Screenshot The above screenshot shows the successful execution of my geoprocessing script in ArcGIS Pro. The script performed the following tasks: Added XY Coordinates The script added XY coordinates to the 'hospitals' shapefile. As indicated by the start and end times, this task was completed in just 2.96 seconds. Created a 1000 Meter Buffer A 1000-meter buffer was created around each hospital. This step took a bit longer, with a completion time of 39.50 seconds. Dissolved the Buffers into a Single Feature: The individual buffers were then dissolved into a single, continuous feature. The dissolution process took 37.87 seconds, as shown in the elapsed time. This step could be completed alongside the buffer analysis.  Other Notes Python, especially with ArcGIS Pro, seems flexible and tailored to the user. For example, I could create my own script, which can use functions similar to the model's. This means that if I’m very fami

M3 - Debug & Error Handling

Image
 Script 1 Objective: Fix errors in Mod3_Script1_Template.py to list field names from parks.shp. Flowchart Output for Script 1 After Corrections Script 2 Objective: Fix errors in Mod3_Script2_Template.py to list layer names from TravisCountyAustinTX.aprx. Flowchart Output for Script 2 After Corrections Script 3 Objective: Modify Mod3_Script3_Template.py to handle errors using try-except statements without fixing the errors. Flowchart Output for Script 3 After Try-Except Statements In Mod3_Script3_Template.py, the script is divided into two parts: Part A and Part B. Part A: This part of the script is intentionally left with an error to demonstrate error handling. Instead of the program crashing and not moving further, I used a try-except statement to catch any errors and print an error message. The error message while also print what went wrong before continuing on to Part B. This is a crucial aspect of debugging since it provides immediate feedback on issues within the code. Part B:

M2 - Python Fundamentals

Image
  Screenshot of Successful Script Result Description of Script The screenshot displays the successful results of my Python script execution. The output includes: 1. Printing Last Name: The name "Klinkhamer" is printed as the last name from the list of names. 2. Dice Game Results: The results of a simulated dice game for multiple players. Each player's roll result is displayed along with whether they won, tied, or lost. For example: Tom rolls a 0 out of 6 and loses. Phillip rolls a 13 out of 14 and wins. Mary rolls a 4 out of 8 and gets a tie. 3. Random Integer List Generation: A list of 20 randomly generated integers between 0 and 10 is shown:  [7, 1, 6, 3, 1, 9, 0, 10, 0, 0, 9, 10, 8, 9, 10, 8, 8, 6, 0, 2, 6] 4. Removing an Unlucky Number: The unlucky number 3 is identified and removed from the list. The list after removing the unlucky number 3 is updated and displayed:  [7, 1, 6, 1, 9, 0, 10, 0, 0, 9, 10, 8, 9, 10, 8, 8, 6, 0, 2, 6] This output demonstrates the successf

M1 - Python Environments & Flowcharts

Image
  Python Module 1 Recap: From Scripts to Flowcharts and Zen Principles Converting 3 Radians to Degrees To convert 3 radians to degrees, we use a simple formula: degrees = radians * 180 / pi Below is the flowchart illustrating the conversion process: Running the calculations in IDLE gives us:  ≈ 171.887 Interpretation of the Zen of Python The "Zen of Python" showcases the philosophy and guiding principles of Python programming. It emphasizes simplicity, readability, and clarity in code. In other words, “Zen of Python” promotes straightforward and elegant solutions over complicated ones. By valuing explicitness over implicitness, the basis of Python encourages clear and understandable code. Moreover, The principles highlight the importance of practicality and avoiding unnecessary complexity— why use 4 lines of code when 1 will do the same thing? This mentality helps to balance between purity and practicality. Overall, the “Zen of Python” advocates for writing code that is easy