1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/db.R, R/sfc.R, R/wkb.R, R/wkt.R, R/sp.R,
3%   R/maps.R, R/s2.R
4\name{st_as_sfc}
5\alias{st_as_sfc}
6\alias{st_as_sfc.pq_geometry}
7\alias{st_as_sfc.list}
8\alias{st_as_sfc.blob}
9\alias{st_as_sfc.bbox}
10\alias{st_as_sfc.WKB}
11\alias{st_as_sfc.raw}
12\alias{st_as_sfc.character}
13\alias{st_as_sfc.factor}
14\alias{st_as_sfc.SpatialPoints}
15\alias{st_as_sfc.SpatialPixels}
16\alias{st_as_sfc.SpatialMultiPoints}
17\alias{st_as_sfc.SpatialLines}
18\alias{st_as_sfc.SpatialPolygons}
19\alias{st_as_sfc.map}
20\alias{st_as_sfc.s2_geography}
21\title{Convert foreign geometry object to an sfc object}
22\usage{
23\method{st_as_sfc}{pq_geometry}(
24  x,
25  ...,
26  EWKB = TRUE,
27  spatialite = FALSE,
28  pureR = FALSE,
29  crs = NA_crs_
30)
31
32\method{st_as_sfc}{list}(x, ..., crs = NA_crs_)
33
34\method{st_as_sfc}{blob}(x, ...)
35
36\method{st_as_sfc}{bbox}(x, ...)
37
38\method{st_as_sfc}{WKB}(
39  x,
40  ...,
41  EWKB = FALSE,
42  spatialite = FALSE,
43  pureR = FALSE,
44  crs = NA_crs_
45)
46
47\method{st_as_sfc}{raw}(x, ...)
48
49\method{st_as_sfc}{character}(x, crs = NA_integer_, ..., GeoJSON = FALSE)
50
51\method{st_as_sfc}{factor}(x, ...)
52
53st_as_sfc(x, ...)
54
55\method{st_as_sfc}{SpatialPoints}(x, ..., precision = 0)
56
57\method{st_as_sfc}{SpatialPixels}(x, ..., precision = 0)
58
59\method{st_as_sfc}{SpatialMultiPoints}(x, ..., precision = 0)
60
61\method{st_as_sfc}{SpatialLines}(x, ..., precision = 0, forceMulti = FALSE)
62
63\method{st_as_sfc}{SpatialPolygons}(x, ..., precision = 0, forceMulti = FALSE)
64
65\method{st_as_sfc}{map}(x, ...)
66
67\method{st_as_sfc}{s2_geography}(
68  x,
69  ...,
70  crs = st_crs(4326),
71  endian = match(.Platform$endian, c("big", "little")) - 1L
72)
73}
74\arguments{
75\item{x}{object to convert}
76
77\item{...}{further arguments}
78
79\item{EWKB}{logical; if TRUE, parse as EWKB (extended WKB; PostGIS: ST_AsEWKB), otherwise as ISO WKB (PostGIS: ST_AsBinary)}
80
81\item{spatialite}{logical; if \code{TRUE}, WKB is assumed to be in the spatialite dialect, see \url{https://www.gaia-gis.it/gaia-sins/BLOB-Geometry.html}; this is only supported in native endian-ness (i.e., files written on system with the same endian-ness as that on which it is being read).}
82
83\item{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 (\code{.Platform$endian}).}
84
85\item{crs}{coordinate reference system to be assigned; object of class \code{crs}}
86
87\item{GeoJSON}{logical; if \code{TRUE}, try to read geometries from GeoJSON text strings
88geometry, see \code{\link[=st_crs]{st_crs()}}}
89
90\item{precision}{precision value; see \link{st_as_binary}}
91
92\item{forceMulti}{logical; if \code{TRUE}, force coercion into \code{MULTIPOLYGON} or \code{MULTILINE} objects, else autodetect}
93
94\item{endian}{integer; 0 or 1: defaults to the endian of the native machine}
95}
96\description{
97Convert foreign geometry object to an sfc object
98}
99\details{
100When converting from WKB, the object \code{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.
101
102If \code{x} is a character vector, it should be a vector containing
103\href{https://www.ogc.org/standards/wkt-crs}{well-known-text}, or
104Postgis EWKT or GeoJSON representations of a single geometry for each vector element.
105
106If \code{x} is a \code{factor}, it is converted to \code{character}.
107}
108\examples{
109wkb = structure(list("01010000204071000000000000801A064100000000AC5C1441"), class = "WKB")
110st_as_sfc(wkb, EWKB = TRUE)
111wkb = structure(list("0x01010000204071000000000000801A064100000000AC5C1441"), class = "WKB")
112st_as_sfc(wkb, EWKB = TRUE)
113st_as_sfc(st_as_binary(st_sfc(st_point(0:1)))[[1]], crs = 4326)
114st_as_sfc("SRID=3978;LINESTRING(1663106 -105415,1664320 -104617)")
115}
116