as_Spatial() allows to convert
sp compatibility. You can also use
as(x, "Spatial") To transform
sp objects to
as_Spatial(from, cast = TRUE, IDs = paste0("ID", seq_along(from)))
object of class
character vector with IDs for the
sp supports three dimensions for
Other geometries must be two-dimensional (
XY). Dimensions can be dropped using
what = "M" or
what = "ZM".
For converting simple features (i.e.,
sf objects) to their
Spatial counterpart, use
geometry-only object deriving from
Spatial, of the appropriate class
nc <- st_read(system.file("shape/nc.shp", package="sf")) # convert to SpatialPolygonsDataFrame spdf <- as_Spatial(nc) # identical to spdf <- as(nc, "Spatial") # convert to SpatialPolygons as(st_geometry(nc), "Spatial") # back to sf as(spdf, "sf")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.