Labels

Thursday, June 9, 2022

GIS 5103 Explore & Manipulate Data

 

Module 4 cranked up the level of difficulty quite a bit.   We also  covered a ton of material in chapters 6 and 8 of our text. We were taught how to check for, describe, and list data. Then , we went on to lists, tuples, and dictionaries. We discussed how "For" loops can be used to iterate over the elements in a list and that elements in a list can be modified through the use of cursors. We learned that tuples are similar to lists, but their elements are immutable. Dictionaries contain keys and corresponding values.

This assignment tasked us to use Python to create a script that would run without error. Our scripts must create a new geodatabase, copy all data from our Data folder into the new geodatabase, and lastly it had to populate a dictionary with the names and population of every ‘County Seat in New Mexico. We were provided with a template that gave us a very basic framework to assist developing our code.

I ran into numerous pitfalls along the way but eventually was successful. Trying to cram too much into a single line of code was problem for me. Stepping back and breaking it down into smaller segments made things go much smoother. It’s very important to be aware of your workspace and to know when to use arcpy.SearchCursor and when to use arcpy.da.SearchCursor! As with every lab so far and for infinity I can’t stress enough SYNTAX, SYNTAX, SYNTAX!


I did a workflow for the creating and populating dictionary portion of this lab. Below is a simplified version that won't give away code details needed to complete the lab:


Completing that segment was the last hurdle to get over on the road to a successful script.

Here is a screenshot of the first portion of the script output:

The next portion had a much longer output. This is for the Search Cursor portion of the code.

The final portion of the lab was to populate the empty dictionary we created and print it.












No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

From Fragmented Data to Actionable Intelligence: A GIS Case Study

  Case Study: Building a Centralized GIS Platform for the Cleveland Museum of Natural History Natural Areas Client: Cleveland Museum of Na...