Skip to content

points to lines and/or polygons

4 messages · Roger Bivand, Agustin Lobo

#
On Tue, 26 Jan 2010, Agustin Lobo wrote:

            
This seems to work at least for SpatialLines - for polygons, the rings may 
need to be closed:

library(StatDA)
data(kola.background)
xy <- kola.background$boundary
names(xy) <- c("x", "y")
library(maptools)
bdy <- map2SpatialLines(xy)
plot(bdy)

The data are in the legacy S format (like the maps package).

Roger

  
    
#
On Wed, 27 Jan 2010, Agustin Lobo wrote:

            
The maps package is the main (geographical) source using the legacy S 
format, where lines (or polygons) are separated by NA rows in a two-column 
matrix. This is described in ?lines. Think of the simplest format for a 
pen plotter, where NA picks up the pen. As the format is used by other 
sources (including base graphics), the function doesn't check that the 
class is "map", but converting from this class is its main use.

Roger