Skip to main content

Python Foundamentals

 In our first week of GIS Programming, I learned the foundations of Python. Wow, was this incredibly hard! I found it extremely challenging to wrap my head around the subtle nuances of syntax and all the different functions and methods available to use. I love puzzles and critical thinking, and that is a huge part of python; coming up with efficient and creative solutions. As I become knowledgeable and better at using python, I am excited to see all the ways I will be able to use it. 

Our Lab this week consisted first of learning how to create a string and then indexing or slicing them. This was the easiest of the tasks, as we learned also to use a while loop in combination with functions(i.e.: range, len, append, random) and methods (i.e.: object.method(argument)). Utilizing the while loop, I debugged a prewritten code that generated random wins and losses for players in a dice game. I also created/utilized a while loop to generate 20 random numbers between 0 and 10. Then I chose an unlucky integer and then created an if-else statement to count the number of times said integer repeated in the generated list. Lastly, I wrote another while loop to remove said integer anytime it repeated in the generated list. 

I was stuck on the last couple of steps trying to figure out what the object representation was for the generated list, so I could do list.count(“num”) to count how many times my chosen integer appeared.  My issue was that I forgot to append the list: list.append(n) [where n is the randomly selected numbers]. I then created a if-else statement to print out the list. I also made the list an integer (y) to condense the statement.

 Lastly, I had a hard time removing the unlucky numbers. After a lot of research and some help from classmates on the discussion board, I realized that I had to add the methods len and range. I was originally using a too simple while loop code without any functions. This resulted in the same list of 20 generated numbers as the previous step, while I desired to remove the chosen integer from the list. I had failed to see that I needed to reference the new desired length of the list and the range. 

Below, is the outcome of the final script. 



Comments

Popular posts from this blog

Positional Accuracy: NSSDA

 In this analysis, I compared the street and road intersect data collected for Alburquerque, NM by the City of Alburquerque and the application StreetMaps. I used an orthophoto base layer as the reference for this analysis, to compare and determine the accuracy of both the City and Streetmap layers using NSSDA procedures. The most difficult part of this analysis for me was how to determine what 20% per quadrant looks like. Because the reference map was divided into 208 quadrants, I had to determine how to subdivide all the quadrant's equality into 20%. After multiple trials and error, I decided to subdivide the entire area (208 sub-quadrants) into 4 equal-area subsections. In this way, I could do 5 random right intersection points per subsection or 20% per subsection.  Map 1: City of Albuquerque city map data.  Map 2: City of Alburquerque SteetMap data When selecting a random intersection to place the points within each quadrant, I choose a location that had data f...

Utilizing ERDAS Imagine to Analyze Map Features

 This week we learned how to utilize histograms and different bands to highlight different features in a map. On the following map that we worked on, dark bodies of water caused high peaks on the left of histograms while snow-peaked mountains were small blips on the far right. These simple distinctions help to quickly identify map features on a graph, that you can then utilize as a stepping stone to finding them on the image. I found it incredibly interesting how the different band layers highlighted different features on the map. Figure 1 below depicts three different features we found on the image.  Figure 1: Distinct features found on an image using ERDAS Imagine. Feature 1: Large body of water. Feature 2: Snow-capped mountains transitioning to thick vegetation. Feature 3: Shallow turbulent body of water near urbanized land, transitioning to deep calm body of water. 

Choropleth and Dot Mapping

 This week we explored choropleth and dot mapping. Choropleth is a thematic form of mapping that focuses on color units, whose color intensity is proportional to its corresponding data value. Dot mapping is also thematic. It uses either a proportional or graduated thematic symbol (like a circle), whose size increases due to its data value. Using ArcGIS pro, I analyzed the population densities of countries in Europe (person per square kilometer), as well as their wine consumption (liters per capita) to determine if there was a correlation between the two. In my choropleth map, I decided to use a natural breaks classification. I chose not to use Equal Interval because only 2 classes (with slight 3 rd class) were represented in the map, and it looked like almost just one color in the lower range. The standard deviation classification appeared to be more diverse at first glance but was actually skewed to the top ranges. I was then between Quantile and Natural Breaks. While both t...