Module 5 Lab

 


We were tasked with writing a script that creates a geodatabase, copies all feature classes from a data folder into it, then populates a dictionary with the names and populations of New Mexico county seat cities. This was by far the largest and most complicated script project I have done so far. It was without direction so I had to outline what I was thinking and try lines of commands to see if they would work and put it all together in the outline. One of the main issues I was toward the beginning of my process. I didn’t really understand what setting arcpy.env.workspace was doing. I thought it was just setting a default folder, but it actually controls where ArcPy looks for data and sometimes even affects how tools behave. When it was pointing to the wrong folder, ListFeatureClasses() just returned nothing, and I had no idea why. I also had so many issues with file paths like forgetting to use raw strings (r""), accidentally adding extra slashes, or copying paths from Windows with backslashes that messed things up in Python. Some tools worked anyway, which made it even more confusing. When doing the scripts working with the attribute table I had the right feature class and fields, but the cursor still didn’t return anything. It turned out I had written the wrong where clause. There were no syntax errors so it just silently didn’t work because the field value didn’t match exactly, or I forgot the quotes. And probably my most frustrating issue was that I was using the full filename like "cities.shp" as the output name when copying shapefiles into the geodatabase, and it kept failing. I eventually figured out that you’re not supposed to include .shp in the name when copying to a file geodatabase so I had to use Describe().baseName to fix that. I learned that a lot of the problems weren’t complex bugs, they were small details I overlooked, like missing a quote, using the wrong cursor, or pointing to the wrong folder. Being careful and trying parts of the script throughout my progress really helped me catch these.

  

Comments

Popular posts from this blog

About Me

M1 Lab: Visual Interpretation

Module 3 Map Sharing and Projections