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

Bivariate Choropleth and Proportional Symbols

In the first part of this lab, we used proportional symbols to represent positive and negative values in job increases/decreases in the USA.  Because there were negative values in this data set, I created a new map to "fix" the data. In this new map, I created a new field and copied the negative job loss data. I then used the Calculate field data and multiplied it by one to make it positive. Lastly, I overlaid both maps on the data and was able to accurately represent the increase and decrease of jobs in the USA by state.   In the second part of this lab, we delved into how to prepare data for a bivariate choropleth map, choose colors for the legend, and create a good layout.  I created three separate fields to analyze the data: Class Obese, Class Inactivity, and Class Final. I used the symbology tool to create 3 Quantile for the Obese and Inactivity classes and used each quantile to set the three classifications in the fields I created using the Select by Attributes tool to

Infographic's

 This week was a fun and challenging week as we learned about and created infographics. It was fun to create the infographics themselves, but challenging to figure out the best methods and practices in analyzing raw data.  We used 2018 County Health Rankings National Data from countyhealthrankings.org. I chose to move forward with the two values: Unhealthy Mental Days and Premature Dealth.  I   choose these two variables because those that struggle with mental health die before their time due to depression, anxiety, and/or a combination of similar issues. Both variables are normalized by relating their value to all counties within each state in the USA. For example, the poor mental health days is normalized as the average number of reported mentally unhealthy days per month per ctizen. The normalized premature rate is the “age-adjusted years of potential life lost rate per 100,000.”  Below, I created a scatterplot of the normalized data.  I choose to keep the scatterplot in a pretty tr

Color and Choropleths

This lab was very interesting as we dived into color theory.  In the first part of the lab, we created and compared linear and adjusted progression color ramps to themselves as well as a color ramp from the website colorbrewer.org.  I found, the colorbrewer color ramps are not as rhythmic when compared to the other methods, as they don’t step up at set intervals or rates. However, I don’t think that a set rate is needed to go from color to color. I preferred the colorbrewer ramp because each color was distinct from its neighbors. In the linear and adjusted color ramps, the colors looked too similar to each other and were not distinct enough for each step. I think that as long as the color ramp is moving in the opposite direction of the same color hue, the step rate or interval is not as relevant. When I first was completing the linear step I started with the purple hue option but had a difficult time, as each step in the color ramp looked the same. At one point, I created my own color