Chapter 5 Mapping Vector Data
5.1 Map point vector data of superfund sites
Alrighty! Now our data seems to be prepared and we can move on to mapping our data.
First things first, this website will be extremely useful in producing leaflet maps : https://rstudio.github.io/leaflet/.
Let's map the superfund sites.
Start by calling
leaflet()- this tells R that we want to create an interactive map using the leaflet package. Next, we want to add a basemap (a background). To do this, we tell R
addTiles(). Note: the
%>% symbols tell R to add another layer to the map.
Now, we have an interactive map interface and a background map. Naturally, the next step is actually adding our data to the top of the map. Before we add our data to the map we have to consider: What type of data is our superfund dataset? In this case, it's point vector data, where each point represents the location of a superfund site. We use the function
addMarkers() to add point data to the leaflet map.
leaflet() %>% addTiles() %>% addMarkers(data = superfund_projected)
What if we want to add other data types other than point vector data? We just need to change the function name that calls the data.
addMarkers()adds point vector data
addPolylines()adds line data
addPolygons()adds polygon data
addRasterImage()adds raster data to a map.