O'Reilly logo

R Data Analysis Cookbook by Shanthi Viswanathan, Viswa Viswanathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required