1. Learn
  2. /
  3. Courses
  4. /
  5. Building Dashboards with shinydashboard

Exercise

sf plots with plot()

As you have seen, sf objects can be plotted using the base R plot() function. The first plot will allow you to set up the base for the map, and subsequent layers can be added using plot().

In the following, there are four sf objects stored as:

  • london_poly
  • london_loop
  • london_capital
  • num_listings

Complete the code below to obtain a geospatial map using plot() to piece sf objects together. Use st_geometry() to ensure that all objects are indeed sf objects when plotted.

The sf and tidyverse libraries have been loaded.

Instructions

100 XP
  • Plot the first layer which is a multipolygon called london_poly.
  • Plot london_loop and color it purple.
  • Plot london_capital and color it green.
  • Add red markers for each point in num_listings.