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

If you have not already done so, you should read the Importing ESRI shape files to R recipe from this chapter.

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

In step 2, readOGR is used to read the ESRI shape files of countries and airports.

Step 3 shows you how to plot the countries without color using the plot function. The plot function plots several polygon objects in countries_sp.

Step 4, similar to step 3, plots countries but adds color to them.

Step 5 adds the airport information using the plot function with the add=TRUE option. The airports_sp object contains several points and the plot function plots each point with specified properties such as plot character and size.

In steps 6 and 7, the use of the spplot function ...

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