Wednesday, May 29, 2024

Module 3- GIS Programming- Debugging and Error Handling

 This week’s assignment focused on diagnosing errors and debugging scripts. We learned several different types of errors and techniques for identifying errors and debugging, notably using try-except statements.

We were given 3 error-filled scripts to fix in IDLE. For the first script we had to identify and correct syntax errors. I fixed the first one easily but got stuck on one for quite a bit.  Without giving away the answer, I was stuck trying to figure out what was wrong with the variable for quite awhile before realizing I was misunderstanding how the words in a loop worked.

I was able to work through most of the errors in the second script methodically but ultimately, I ended up with the script running and giving me the appropriate output, but still giving an error. This took a while for me to resolve and after trying several things that only made the script not run, I realized that it was because I still had the script open in ArcGIS Pro. Once I closed the program the script was able to run and give me the requested output.

The third script required us not to directly fix the error but to add a try-except statement that allowed the script to run but to print the error instead of terminating the script. I was able to quickly identify where the issue in the script was and where to put the “try” statement but had a more difficult time figuring out where to put the “except” statement. I ended up adjusting my statement multiple times before I was able to get the desired result. The following flowchart shows the steps I took to debug this particular code.


Here are copies of the output of my debugged scripts:






Wednesday, May 22, 2024

Module 2- GIS Programming- Python Fundamentals

 This week we read about python fundamentals including: if, elif and else; lists, dictionaries and tuples; commonly used methods and function; loops and Booleans. We then practiced implementing these fundamentals both in the practice exercises and module 2 lab.

We were assigned 4 tasks: to print our last name from a created list, to fix errors within a prewritten code set, to populate and empty list with 20 random integers using a while loop with a counter variable. Then to use an “if” statement and a while loop to remove an “unlucky” number of our choice from the previously created list and then reprint the list with this integer removed.

 The first two tasks went smoothly. I created a string of my name and used the split function to create a list of individual names. Then I was able to use the index function to print only my last name. The second task was to correct errors in a provided “for” loop.

The third task was more complicated, but I feel like I learned a lot through this process. I began by creating my empty list and then made sure to import the random module, and began to put together my "while" loop. For my initial code I utilized the “random” function too soon in the script. This resulted in my output simply making a list of 20 duplicate integers. The second script I ran worked perfectly and gave the desired output, but it did not contain a counter variable which was a requirement of the assignment. I wasn’t quite grasping the concept of a counter variable and breaking a loop, so my next script ended up being an infinite loop and crashed the program. Finally, after a bit of re-reading I created a working script that contained all the desired components, however, my output was printing each addition to the list individually as a separate list, so I ended up with a giant triangle of 20 lists each with a single additional number. This was because I accidentally put the “print” function indented under the while loop. By moving it to the left where it belonged and not including it in the loop, I was finally able to print a single list of 20 randomly generated integers.

The final task built upon task 3. We were to remove an “unlucky” number (integer of our choice) from the list generated in the last task. We were to include an “if” statement to print one of two statements. If the integer was absent, we were to print that it was not in the list. If it was present we were to print a statement saying that the integer would be removed from the list for the total count of times it was included in the list. We were then to use a “while” loop to remove the integer from the list for the “count” of times it was present. I initially typed my print statements in my “if/else” statement with the integer itself in the string but I quickly realized I should reference the variable (unlucky is what I designated it) as a string within the code in order to create a code that was more efficient and could be changed by simply changing the variable if I desired, so I made sure that instead of typing “9 is not in the list” I would make sure the “9” was actually str(unlucky). I tested this by changing the variable to another integer and the code ran smoothly and changed easily along with the newly generated list and newly chosen integer. I finally was able to print the list with the number removed and completed the assignment, here is an image depicting my final output followed by a flowchart showing the steps I took to complete the task.








Tuesday, May 14, 2024

Module 1- GIS Programming- Python Environments and Flowcharts

 The first week of GIS Programming has commenced. I was nervous going into this class as I have no coding experience, but I am excited to learn something new. This week we learned the very basics of python and practiced making flowcharts. Our first task was to run a pre-scripted code that created all the folders we would need for the course. As I looked at the code, I noticed how easy it would be to slightly alter this code to use for other courses, assuming one was following a consistent folder pattern for each module. I find the functional aspect of coding interesting because I haven’t understood or considered all the different tasks it can be used to streamline before now.

One aspect of coding I think is less intuitive to me at this point is knowing what values to define. I could easily see myself forgetting to define a value when setting up my codes, especially as the codes get progressively more complex. I presume that it will become more instinctive with time/practice. In the case of this week’s assignment, which was to create a flowchart for a simple math calculation, it was such a different way of looking at a simple math problem- having to input each piece separately before putting it all together. When I began putting my flowchart together, I was unsure if “pi” would be a known or unknown variable in python so decided to test it by running the code to determine degrees based on my flowchart. It told me that there was an “error” with variable the variable “pi”. I tried again but added that pi=3.14159 and it gave me to output so I made sure to define that variable to my flowchart. I had run a google search before “testing” my equation and found that there is some way to use a math module or library that would allow me to simply use “pi” without declaring it but for the purposes of this lab didn’t investigate it further since we weren’t tasked with running the code at this time. However, I do want to follow up and figure out how that works at a later point if it is not covered in future labs.

A flowchart depicting the calculation of degrees when radians=3

Our last task was to access and read “The Zen of Python” and share what we think it means. I read “The Zen of Python” as a set of guidelines to consider when developing scripts using this program. It makes clear that the developers of python value clarity (with statements such as “explicit is better than implicit”), and simplicity (by defining a simple>complex>complicated hierarchy, and a preference for sparse over dense and flat over nested). This work makes clear that the purpose of python is not flashy/overcomplicated scripts but rather the beauty of python lies in ease of use. Fortunately for me, this challenges my previously contrived ideas of what coding would look like as I imagined it to be a very difficult, complicated process.


Wednesday, April 24, 2024

Module 7- Cartography- Google Earth

 This week focused on converting map layers to KML files and uploading to Google Earth as well as creating a Google Earth Tour. The tour was a neat feature I'd never experimented with. For our map and tour we focused on south Florida.  The map created was a dot density map with surface water layers added. Before we uploaded our layers to Google Earth we practiced using the Layer to KML tool to convert the layer into a format that could be used in Google Earth. We also learned how to organize layers and add images in Google Earth. 

The tour was an overview of major Florida metropolitan areas. After creating placemarks for each area I wanted to feature, I gave an view of the entirety of south Florida and the zoomed in and out on the placemarks then panned and zoomed in, out and around the downtown areas. 

Here is a copy of my Google Earth map.



Wednesday, April 17, 2024

Module 6- Cartography- Isarithmic Map

 For this week’s exercise we focused on two methods of presenting data on an isarithmic map: continuous and hypsometric. We used PRISM annual precipitation data obtained from the USDA NRCS National Geospatial Management Center in coordination with the PRISM Group at Oregon State University for the state of Washington from 1981-2010.

First, we created a map presenting the precipitation data in continuous form. We also created our own hillshade layer to add to our map display elevation since this effect hasn’t been added to ArcGIS pro yet. Then we created a second map in which we converted the data to a hypsometric tint to better visualize the precipitation totals. To do this we used the Int (Spatial Analysis) tool to convert the raster data to integers. We then created 10 manual intervals to classify the data. We added our hillshade layer and added contour lines using the Spatial Analysis Contour List to add contour values. Finally, we were tasked to create a map layout and to include a description of how the data was interpolated.

When reviewing the differences in the continuous and hypsometric maps and answering the process summary questions I was reminded of a recent map I’d viewed on my local weather station’s website. Sure enough, both the tornado risk and predicted precipitation totals were shown on a hypsometric isarithmic map similar to the one I created.




 

 

 

Thursday, April 11, 2024

Module 5- Cartography- Choropleth and Proportional Symbol Mapping

 For lab 5, I was tasked to make a map depicting the population densities of European countries as a choropleth and wine consumption for those countries as a graduated or proportional symbol using ArcGIS Pro. I incorporated data classification and map design principles learned from the past several modules.

Using Data from Eurostat and the Wine Consumption institute, I constructed a map meeting the appropriate parameters. I hit two major snags that took me awhile to resolve. At first, I could not figure out why the labels I wanted to exclude from my map were not excluded. After almost an hour I realized that I was supposed to use an “and” clause rather than the “or” clause we used earlier for data exclusion. This confused me because I understood “and” to require the associated feature to meet all the parameters listed, but I had never worked with a negative statement before and when using “is not equal to” then “and” is the appropriate choice. I anticipate that the programming course offered this summer will help me better understand this aspect of the software.

The second snag I hit was moving my symbols on the map. I didn’t realize that even though the wine consumption data was symbolized using graduated circles, the feature class itself was classed as polygon data. One of the module leaders found an article that helped clear this up for me. To be able to move the symbols I had to convert the data to a point feature. This solved my issue, but it was a headache because all my previous work (setting the classes, excluding the appropriate data, creating my labels, etc.) had to be redone on the new feature class.

I used the histogram to study the intervals made with the classification data. I used Natural Break classification for the population density data, but this posed an issue, one that I foresee would have been an issue for any classification method other than equal interval. For my inset map I needed to exclude the data from the Balkan region on my main map. By excluding this data it “altered” my natural breaks. Then, on my inset map which included those countries, the Natural breaks were representative of Europe as a whole, which meant some of the countries were classified differently and the break points were not the same for both maps. I ended up using the break points of the totality of Europe and set manual break points on the main layout.

I used equal intervals to classify my wine consumption data. Looking at the histogram I felt like this split the data in a way that was meaningful.

Overall, I found this project very insightful and learned many new strategies I feel will be helpful going forward. Even though I had several struggles that added significant time to the process I know that this further reinforced the information I took in.

Here is my map:



 

Thursday, April 4, 2024

Module 4- Cartography- Data Classification

     For this week’s lab we compared four different data classification methods and identified the most appropriate method for visualizing the spatial data provided. Our data source was the 2010 US Census Tract in Miami-Dade County obtain by FGDL, and we were tasked with representing the population of seniors (65 and up) by both percentage of the population for each tract and by normalizing the data to show the number of senior citizens per square mile. To do this we created two maps, both comparing four classification methods- Natural Break, Equal Interval, Quantile, and Standard Deviation.

We were tasked to explain how each classification method differs as well as which method of classification (by percentage or per square mile) was a more accurate representation of the distribution of senior citizens. I concluded that since census tracts were specifically designed to have uniform populations the percentage of senior citizens was the best choice for representing this data set. Normalizing the data by square mile favors smaller census tracts even if the senior population is significantly less than a larger tract. In order to obtain a more accurate “per square mile” comparison I proposed that the county should be equally divided by area to get a more accurate visual of population density.

Map 1 depicting the four classification methods representing the distribution of citizens by percentage of the population
 

Of the four classification methods, I believe that the Natural Break is the most accurate representation of the data. The data contains an outlying tract consisting of 79% of the population being 65 or older. This skews the data slightly to the right. The Natural Break method accounted for this outlier while still breaking up the classes into categories that are a cleaner representation of the data. The equal interval method contained an empty class due to the presence of an outlier and grouped the majority of observations in the lower classes. It failed to provide insight into which tracts other than the outlier contained a higher density of senior citizens. The quantile method grouped the outlier with significantly lower population categories which masked its status as an outlier and might lead to inaccurate assumptions about the population represented in those tracts. Standard deviation is not the best representation due to skewedness of the data as well as the presumed audience.

I found this exercise very helpful in solidifying my understanding of the lecture material, how each classification method works, and under which circumstances they are best suited for creating an accurate representation of spatial data.

 

GIS Portfolio

 We were tasked to create a GIS portfolio for our internship program. It was a great opportunity to put organize the work I have been doing....