CommencerCommencer gratuitement

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!

Cet exercice fait partie du cours

Visualizing Geospatial Data in R

Afficher le cours

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.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Call summary() on countries_spdf and countries_sp



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


# Plot countries_spdf
Modifier et exécuter le code