Learn R Programming

sf (version 0.4-3)

st_as_sfc: Convert foreign geometry object to an sfc object

Description

Convert foreign geometry object to an sfc object

Usage

# S3 method for list
st_as_sfc(x, ..., crs = NA_crs_)

# S3 method for WKB st_as_sfc(x, ..., EWKB = FALSE, spatialite = FALSE, pureR = FALSE, crs = NA_crs_)

# S3 method for character st_as_sfc(x, crs = NA_integer_, ...)

# S3 method for factor st_as_sfc(x, ...)

st_as_sfc(x, ...)

# S3 method for SpatialPoints st_as_sfc(x, ...)

# S3 method for SpatialPixels st_as_sfc(x, ...)

# S3 method for SpatialMultiPoints st_as_sfc(x, ...)

# S3 method for SpatialLines st_as_sfc(x, ..., forceMulti = FALSE)

# S3 method for SpatialPolygons st_as_sfc(x, ..., forceMulti = FALSE)

# S3 method for map st_as_sfc(x, ...)

Arguments

x

object to convert

...

further arguments

crs

integer or character; coordinate reference system for the geometry, see st_crs

EWKB

logical; if TRUE, parse as EWKB (extended WKB; PostGIS: ST_AsEWKB), otherwise as ISO WKB (PostGIS: ST_AsBinary)

spatialite

logical; if TRUE, assume the WKB is assumed to be in the spatialite dialect, see https://www.gaia-gis.it/gaia-sins/BLOB-Geometry.html

pureR

logical; if TRUE, use only R code, if FALSE, use compiled (C++) code; use TRUE when the endian-ness of the binary differs from the host machine (.Platform$endian).

forceMulti

logical; if TRUE, force coercion into MULTIPOLYGON or MULTILINE objects, else autodetect

Details

when converting from WKB, the object x is either a character vector such as typically obtained from PostGIS (either with leading "0x" or without), or a list with raw vectors representing the features in binary (raw) form.

if x is a character vector, it should be a vector containing the well-known-text representations of a single geometry for each vector element

if x is a factor, it is converted to character

Examples

Run this code
wkb = structure(list("01010000204071000000000000801A064100000000AC5C1441"), class = "WKB")
st_as_sfc(wkb, EWKB = TRUE)
wkb = structure(list("0x01010000204071000000000000801A064100000000AC5C1441"), class = "WKB")
st_as_sfc(wkb, EWKB = TRUE)

Run the code above in your browser using DataLab