Introducing sp objects

Visualizing Geospatial Data in R

Charlotte Wickham

Assistant Professor at Oregon State University

Data frames aren't great for storing spatial data

head(ward_sales)
  ward       lon      lat group order num_sales avg_price 
1    1 -123.3128 44.56531   0.1     1       159  311626.9 
2    1 -123.3122 44.56531   0.1     2       159  311626.9 
3    1 -123.3121 44.56531   0.1     3       159  311626.9 
4    1 -123.3119 44.56531   0.1     4       159  311626.9 
5    1 -123.3119 44.56485   0.1     5       159  311626.9 
6    1 -123.3119 44.56430   0.1     6       159  311626.9 
  • No easy way to keep coordinate reference system information
  • Inefficient for complicated spatial objects
  • Hierarchical structure gets forced into a flat structure
Visualizing Geospatial Data in R

The sp package

  • Provides classes for storing different types of spatial data
  • Provides methods for spatial objects, for manipulation
  • Is useful for point, line and polygon data
  • Is a standard, so new spatial packages expect data in an sp object
Visualizing Geospatial Data in R

Let's practice!

Visualizing Geospatial Data in R

Preparing Video For Download...