Creating spatial data frames by combining regular data frames with spatial objects
Often we have data that has some geographical aspect to it (such as postal codes) but does not have sufficient geographic coordinate information for plotting. In order to display such information on a map representation, we will need to embellish the basic data with enough geographic coordinate information for plotting. The
sp package has several
SpatialXXXDataFrame classes to represent geographic information along with additional descriptive data. This recipe shows how we can create and plot such objects. In this recipe, we demonstrate how to get a map from the maps package and convert it into a
SpatialPolygons object. We then add data from a normal data frame ...