[R] Create a map

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Sun Jul 24 10:40:54 CEST 2011


On Sat, Jul 23, 2011 at 10:04 AM, Amy Ruiz <amyruiz91 at gmail.com> wrote:
>  Hello:
> I'm using the library of maps, however, I need to use a map of Puerto Rico, but
> apparently does not exist. I wanted to know if there is any way that I
> can create
> that map?

 The 'maps' package (not 'library') is a bit old and getting data for
it can be a bit tricky.

 The 'sp' package and its friends such as maptools, rgdal, and raster
are the way to go. They can work with standard geospatial data files,
which are commonly available.

 So, I suggest you install those packages, and then get a shapefile of
Puerto Rico - there's one at www.gadm.org which shows the
administrative regions. Plotting that could be as simple as:

 library(maptools)
 pr = readShapeSpatial("PRI_adm.shp")
 plot(pr)

 - haven't tested that exactly, but its about right.

 Spatial and mapping questions are best directed to the R-Sig-Geo mailing list.

 Hope that helps.

Barry



More information about the R-help mailing list