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
Exercise instructions
- Call
summary()
oncountries_sp
and then on this new objectcountries_spdf
(one at a time). What kind of object is this? What differs between this andcountries_sp
? - Call
str()
withmax.level = 2
oncountries_spdf
. How does the structure differ fromcountries_sp
? - Call
plot()
oncountries_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