Task 1: Reflection

Plotting features on a map is much easier now than in the past. Maps can sometimes reveal hidden information in data but also, maps not used properly can misinform an audience. One is not supposed to accept any data plot just because it is on a map. There is a need to be able to identify which map is fake and which is not. Choropleth is a perfect way to visualize data on a map. However, it can hide patterns due to the differences in population sizes. One way to solve this is to plot points and map the size aesthetic to the population. Using fill values can sometimes cause distortions and hide small proportions. Real live globe is three-dimensional and this makes it difficult to project a map. This provides several methods to project a map and one needs to know which choice fits what story one wants to tell. A map can be suitable for global plots and not do well for country or state plots. Projection choice depends on the context of your plot and the need to not distort the truth

Task 2: World map

library(tidyverse)
library(sf)
library(viridis)
windowsFonts("Roboto Condensed"= windowsFont("Roboto Condensed"))


# Load and clean internet user data
internet_users <- read_csv("data/share-of-individuals-using-the-internet-1990-2015.csv") %>%
  # Rename country code column to ISO_A3 so it matches what's in the Natural Earth shapefile
  rename(users = `Individuals using the Internet (% of population) (% of population)`,
         ISO_A3 = Code)

# Load world shapefile from Natural Earth
# https://www.naturalearthdata.com/downloads/110m-cultural-vectors/
world_shapes <- read_sf("data/ne_110m_admin_0_countries/ne_110m_admin_0_countries.shp")
# Only look at 2015
users_2015 <- internet_users %>%
  filter(Year == 2015)

users_map <- world_shapes %>%
  left_join(users_2015, by = "ISO_A3") %>%
  filter(ISO_A3 != "ATA")  # No internet in Antarctica. Sorry penguins.

Make a map showing the proportion of individuals in each country that had access to the internet in 2015.

# TODO: Make a map of internet users with ggplot() + geom_sf()
# Important: Remember to consider the map projection
ggplot() +
  geom_sf(data = users_map, size =5, aes(fill = users)) +
  coord_sf(crs = st_crs("ESRI:54030"))+
  scale_fill_viridis_c(option = "viridis") +
  theme_void()+ theme_bw(base_family = "Roboto Condensed")+
  labs(title = "INDIVIDUALS USING INTERNET IN 2015", subtitle ="PERCENTAGE OF POPULATION PER COUNTRY",
         caption = "DATA SOURCE: https://ourworldindata.org/internet and NATURAL EARTH")+
   theme(legend.position = "bottom")

Task 3: Personal map

Draw your own map with your own points. This could be a map of places you’ve lived, or a map of places you’ve visited, or a map of places you want to visit. Anything!

The only requirement is that you find an appropriate shapefile (states, counties, world, etc.), collect latitude and longitude data from Google Maps, and plot the points (with or without labels) on a map. Use multiple shapefiles if you want—add roads, rivers, lakes, whatever. Basically follow the code from the example in the section named “Making your own geocoded data”.

#loading newyork map

us_states<- read_sf("data/cb_2022_us_state_20m/")



Newyork<- us_states %>% 
  filter(NAME == "New York")

#creating newyork counties map

us_counties<- read_sf("data/cb_2022_us_county_5m/")

#creating newyork counties

newyork_counties<- us_counties %>%
  filter(STUSPS == "NY")



#NEWYORK MAP WITH COUNTIES

ggplot()+
  geom_sf(data = Newyork)+ theme_void()+ geom_sf(data = newyork_counties, fill= "green")+
  coord_sf(crs = st_crs("ESRI:54030"))+ geom_sf_label(data = newyork_counties,aes(label= NAME))

#adding newyork city hall to the map



city_hall <- tribble(
~Location, ~lat, ~long,
"Newyork_city_hall", 40.712772, -74.006058) %>%
#now we convert the dataset into a shape file
st_as_sf(coords = c("long", "lat"), crs = 4326)


# plotting ney york city hall in the data set
ggplot()+
  geom_sf(data = Newyork)+ theme_void()+ geom_sf(data = newyork_counties, fill= "green")+
  coord_sf(crs = st_crs("ESRI:54030"))+ geom_sf(data = 
                                                  city_hall, col=
                                                  "yellow")+
                                                  geom_sf_label(data = city_hall, aes(label = Location,
                                                                                      hjust = 1.1))+
  labs(title = "LOCATION OF NEW YORK CITY TOWN HALL", caption = "DATA SOURCE: GOOGLE")
## Coordinate system already present. Adding new coordinate system, which will
## replace the existing one.
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data