1. Learn
  2. /
  3. Courses
  4. /
  5. Visualizing Geospatial Data in R

Exercise

A more complicated spatial object

You probably noticed something a little different about the structure of countries_sp. It looked a lot like a list, but instead of the elements being proceeded by $ in the output they were instead proceeded by an @. This is because the sp classes are S4 objects, so instead of having elements they have slots and you access them with @. You'll learn more about this in the next video.

Right now, let's take a look at another object countries_spdf. It's a little more complicated than countries_sp, but you are now well-equipped to figure out how this object differs.

Take a look!

Instructions

100 XP
  • Call summary() on countries_sp and then on this new object countries_spdf (one at a time). What kind of object is this? What differs between this and countries_sp?
  • Call str() with max.level = 2 on countries_spdf. How does the structure differ from countries_sp?
  • Call plot() on countries_spdf.