Working with spatial elements is what got me interested in learning R in the first place. But I must admit, it was very overwhelming at first.
What follows is a walkthrough that goes over the key spatial elements needed to understand how to conduct an introductory-level of spatial analysis in R.
To follow the tutorial, you’ll need to install the following packages installed:
sp: classes and methods for spatial data.
rgdal: bindings for the Geospatial Data Abstraction Library.
splancs: spatial and space-time point pattern analysis.
dplyr: data manipulation.
magrittr: set of operators which make your code more readable.
pander: provide a minimal and easy tool for rendering R objects into Pandoc’s markdown.
install.packages( c( "sp", "rgdal", "splancs"
, "dplyr", "magrittr", "pander"
)
)
Polygons on a map represent natural or artificial borders used to mark on space apart from another. In Chicago, a common series of polygons are the 77 Community Areas that make up the entire city.
Fortunately, importing polygons into R is easy.
The data for this tutorial comes from the City of Chicago’s Open Data Portal:
City of Chicago’s open data portal is a lets you find city data, find facts about your neighborhood, lets you create maps and graphs about the city, and lets you freely download the data for your own analysis. Many of these data sets are updated at least once a day, and many of them updated several times a day.