# Assignment 4 – Data Visualization

In this assignment, I represent the countries of the world and their population growth over the years on a world map.

To start off, I downloaded the dataset from https://data.worldbank.org/indicator/SP.POP.TOTL. The dataset shows the countries of the world, and the respective populations of each year from 1960 to 2021. As the dataset only contained the country names and not their latitudes and longitudes, I used the Google Sheets extension “Geocode by Awesome Table” to generate the lats and lons of each country. I cleaned up the data by removing all rows where the longitudes and latitudes could not be generated.

Once the data was ready, I read through the csv and generated points for each longitude and latitude. I then added a map of the earth in the background and adjusted the lans and lats to match the borders of the countries as accurately as possible. To ensure this was successful, I also printed the names of all the countries along with their points to give me a better idea about where to place the dots approximately. Initially, I mapped the population of 2021 for all countries only for making sure the program runs fine.

After this was implemented, I used the map() function to change the size of the ellipses and their colors based on the population of the country. This was done by initially finding the min and the max population from the entire dataset along with min and max latitudes and longitudes.

Once I had the basic functioning code for the year 2021, I edited the code to run for all years. As the code was too slow when the years were only incrementing by 1, I changed it to make the years increment by 10 each time.

Reflection

I found it quite challenging to update the canvas without removing the ellipses which represented the population for the previous year. If I updated the background image each time the draw function was run, all ellipses was erased. And, if I only updated it every time the year was incremented, all the previous ellipses were erased due to which it was difficult to estimate population growth over the years. To solve this problem, I went through P5 references to understand multiple functions which may help me to solve the problem such as erase() and clear() but none of them helped. Eventually, I settled on only initializing the background once in setup but adding a black rectangle behind the text so I can update it every time without the years being overwritten on top of each. One aspect in which I believe this piece could have been further improved is by showing the growth of all the circles more dynamically instead of one being drawn over another.