Let's take a look at a spatial object
We've loaded a particular sp
object into your workspace: countries_sp
. There are special print()
, summary()
and plot()
methods for these objects. What's a method? It's a special version of a function that gets used based on the type of object you pass to it. It's common when a package creates new types of objects for it to contain methods for simple exploration and display.
In practice, this means you can call plot(countries_sp)
and if there is a method for the class of countries_sp
, it gets called. The print()
method is the one called when you just type an object's name in the console.
Can you figure out what kind of object this countries_sp
is? Can you see what coordinate system this spatial data uses? What does the data in the object describe?
This exercise is part of the course
Visualizing Geospatial Data in R
Exercise instructions
- Print
countries_sp
. Why isn't this very useful?. - Call
summary()
oncountries_sp
. - Call
plot()
oncountries_sp
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
library(sp)
# Print countries_sp
# Call summary() on countries_sp
# Call plot() on countries_sp