Posts

Showing posts from June, 2024

Module 6: Geometries

Image
The assignment for this week took many of the topics from past modules to create a script using ArcGIS Pro Notebook to perform the following task:  Create a search cursor for the rivers shapefile and creating a TXT file to add the results of the OID, vertex number, coordinates, and name for each point of each river feature.  A psuedocode of the final script is included below:  The first thing in the script is to import the env, arcpy, os, and fileinput, and set the workspace to an output folder. Also, the overwrite.output needed to be included so that the script can be run multiple times and overwrite the previous files. Then the search cursor is used to search for the OID (OID@), feature (SHAPE@), and river name (NAME). The results were set at the cursor variable. A for loop is used to define each row in the cursor, with a nested for loop to define the every point of each river feature, as polylines are made of multiple points. To create a sequence of vertices, another ...

Module 5 - Explore and Manipulate Data

Image
Module 5 explored using and manipulating data in ArcGIS Notebook and IDLE. A cities location shapefile was provided that included the city name, classification, and the population density in the attribute information. A list of tasks was assigned and needed to be completed by writing a Python script.  The first task was to create a new geodatabase and copy all the shapefiles into the new geodatabase. The names of the new files in the created geodatabase needed to use the basename property from the arcpy.Describe() function. Therefore, the file name would be something like cities.shp and not cities.shp.shp.  The second task was to create a Search Cursor for the cities feature class, in which the cursor should only retrieve the !NAME!, !FEATURE!, and !POP_2000! fields only for the cities classified as 'County Seats'.  The last task was to create a dictionary of the city name and population in 2000. To do this, the script format below was added under the for row in cursor s...

Module 4 - Geoprocessing

Image
Using ModelBuilder in ArcGIS Pro is an excellent tool to streamline repetitive or complex processes. For this module, the goal was to create a model (part A) and a script (part B) from scratch. Models on ArcGIS Pro look very similar to flowcharts and run from the starting input feature, though the tool process, and then produces an output feature that could then be linked to another tool process to create another output feature. The assignment for part A is the following:  Clip all soils to the extent of the basin Select all soils that are classified as "Not prime farmland" under the [FARMLNDCL] attribute Erase the "Not prime farmland" soil selection from the clipped soils basin polygon The soils data (polygons) was the input feature of the model. These data were clipped using the CLIP geoprocessing tool. An image of the soils data before clipping to the basin footprint is below: The soils after clipping to the basin and selecting/deleting the soils that are classif...

Module 3 - Debug and Error Handling

Image
This week focused on Debugging and Error Handling. Three scripts were provided, in which each script contains multiple errors that prevented the script from creating the intended output. Script #1 included a syntax error, in that a word was capitalized incorrectly. After correcting the error, the script could run using ArcGIS Pro Notebook and print each of the names of all fields in a provided parks polygon shapefile. A screenshot of the output is shown below:  Script #2 had several errors that needed to be corrected, such as misspelled commands, capitalized letters that should not be capitalized, and using / instead of \ in a text string. The final script needed to print out a comment on the project's spatial reference and list the layers in the map. By running the script and working through and correcting each error message, one line at a time, this produced the final result below:  Script # 3 also included errors. However, the assignment was to use a try-except statement to...