Activity 1: Interactive Maps

Many course participants are interested in displaying spatial information in the form of interactive maps. For this assignment, we have created a draft version of an app that displays the spatial distribution of the largest cities (from a population size perspective) across the world. This app relies on Leaflet, a package within R that can be used together with Shiny to generate these interactive maps. Download the Leaflet activity files and open assignment_map.R to get started.

The goal of this assignment is to improve this app. More specifically, we would like you to:

  1. Add a title to this app

  2. Add a select input to allow users to subset only the cities that belong to a particular country

  3. Add a radio button that allow users to subset only the capital cities.

  4. Create a side bar that will collect all the input that we want from the user (e.g., minimum population size and desired country)

Bonus challenges! If you get through the first four challenges, tackle these in the order you find them most interesting

  1. Add the global May 2020 Normalized difference vegetation index raster file (NDVI_lite.tif) to the leaflet map to visualize global “greenness.” Visualize the variation in vegetation distribution using the r_colors palette created at the top of the script. If you get stuck, check out the leaflet raster documentation.

  2. Add a legend for the NDVI raster

  3. Try adding different provider tiles

  4. If you feel like a real data challenge, try swapping out the dropdown list for a selectize input and let users select multiple countries.

  5. What happens if a user chooses an invalid combination of filters (e.g., a capital city with too large of a population)? Come up with a way to prompt users to choose a valid filter combination.

Once you make the changes described above, check your answers against assignment_map_solution.R. There are multiple ways to accomplish the challenges, so your solution might be different than ours!