Learn R Programming

sf (version 0.5-5)

as: Methods to coerce simple feature geometries to corresponding Spatial* objects

Description

Methods to coerce simple feature geometries to corresponding Spatial* objects

Usage

as_Spatial(from, cast = TRUE, IDs = paste0("ID", 1:length(from)))

Arguments

from

object of class sfc_POINT, sfc_MULTIPOINT, sfc_LINESTRING, sfc_MULTILINESTRING, sfc_POLYGON, or sfc_MULTIPOLYGON.

cast

logical; if TRUE, st_cast from before converting, so that e.g. GEOMETRY objects with a mix of POLYGON and MULTIPOLYGON are cast to MULTIPOLYGON.

IDs

character vector with IDs for the Spatial* geometries

Value

geometry-only object deriving from Spatial, of the appropriate class

Examples

Run this code
# NOT RUN {
nc = st_read(system.file("shape/nc.shp", package="sf"))
as_Spatial(st_geometry(nc[1,]))
# }

Run the code above in your browser using DataLab