O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

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

How it works...

In step 1, the sp and rgdal packages are loaded.

In step 2, the readOGR function from the rgdal package is used to read the ne_50m_admin_0_countries.shp shape file layer. An ESRI shape file comes in layers with all files in a layer having the same filename and different filename extensions. Each file contains some information about the map in a layer. The first argument to the readOGR function specifies the data source name (DSN), or a directory containing the layer, and the second argument specifies the layer to be read.

The result of step 2 shows that readOGR returns an object of the SpatialPolygonsDataFrame class. The sp package defines several spatial classes including SpatialPolygonsDataFrame. This class stores spatial ...

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