Learn R Programming

loon (version 1.4.3)

spAsList: Create a list of polygons or lines from a spatial data object from the sp package.

Description

spAsList is a helper function that should rarely be called directly by the user. It is an S3 generic function which takes the spatial data object and returns its components (polygons, lines, et cetera) in a list. Each element could itself be a list. Different S3 methods are implemented for various spatial data types.

Usage

spAsList(x)

Value

A list of the relevant components of the spatial data object.

Arguments

x

An sp spatial data object.

See Also

spunlist

Examples

Run this code

if (FALSE) {
library(sp)
library(rworldmap)
world <- getMap(resolution = "coarse")
class(world)
isS4(world)
xy <- spAsList(world)

names(xy)
# because tree has same depth for every leaf unlist is ok
# This is not true otherwise.
uxy <- spunlist(xy)
unlist(xy, recursive=FALSE)
names(uxy)

# here, unlist would be wrong.
}

Run the code above in your browser using DataLab