as_sp(obj, what = c("points", "lines", "polygons"), crs = osm_crs(), simplify = TRUE)
osmar
objectwhat
the
osmar
object will be converted into in a
list of objects given by the sp-package:
what = "points"
SpatialPointsDataFrame
.
The data slot is filled with the attrs slot of
obj$nodes
.
what = "lines"
SpatialLinesDataFrame
. It is build
with all possible elements which are in obj$ways
obj$relations
. The data slot is filled with
elements of both.
what = "polygons"
SpatialPolygonsDataFrame
. It consists
of elements which are in obj$ways
slot.
Every conversion needs at least a non-empty
obj$nodes$attrs
-slot because spatial information
are stored in there.
data("muc", package = "osmar")
muc_points <- as_sp(muc, "points")
muc_lines <- as_sp(muc, "lines")
muc_polygons <- as_sp(muc, "polygons")
bbox(muc_points)
Run the code above in your browser using DataLab