Get startedGet started for free

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!

This exercise is part of the course

Visualizing Geospatial Data in R

View Course

Exercise instructions

  • 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Call summary() on countries_spdf and countries_sp



# Call str() with max.level = 2 on countries_spdf


# Plot countries_spdf
Edit and Run Code