Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Spatial2map

Read SpatialPolygons and SpatialLines objects


Description

These functions transform some classes provided by the package sp into a simple list that can be used by map().

Usage

SpatialPolygons2map(database, namefield=NULL)
	SpatialLines2map(database, namefield=NULL)

Arguments

database

A SpatialPolygons or SpatialLines object.

namefield

The name of a data column in database to be used for naming the polygons (or lines). If it is a vector of names, these are all used and separated by a colon ':'. Not case sensitive. So if the database contains columns that only differ by case, you get a warning and namefield is not used at all.

Details

The 'map' list object only preserves co-ordinates and polygon names. All other information available in the original data is lost.

The option namefield is only taken into account if database is class Spatial[]DataFrame. namefield may be a vector of column names, e.g. to get polygons named as 'country:state'.

Value

A list with four components: x, y, names, range, similar to the return value of map(). This data can be used as a database for map(). The lines and polygons are separated by NA.

See Also

map,SpatialPolygons (in the sp library), readShapePoly (in the maptools library)


maps

Draw Geographical Maps

v3.3.0
GPL-2
Authors
Original S code by Richard A. Becker and Allan R. Wilks. R version by Ray Brownrigg. Enhancements by Thomas P Minka and Alex Deckmyn.
Initial release
2018-04-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.