Construct a geometry from OGC Well-Known text (WKT) description.

st_geomfromtext(x, crs = sf::NA_crs_)

Arguments

x

WKT description

crs

coordinate reference system

Value

A geometry (class sfc)

Details

It can be used as an equivalent to type casting in postgis ('POINT(1 1)'::geometry)

Examples

st_geomfromtext('POLYGON((38 16,38 50,65 50,66 16,38 16))')
#> Geometry set for 1 feature #> geometry type: POLYGON #> dimension: XY #> bbox: xmin: 38 ymin: 16 xmax: 66 ymax: 50 #> epsg (SRID): NA #> proj4string: NA
#> POLYGON ((38 16, 38 50, 65 50, 66 16, 38 16))
st_geomfromtext('POINT(-71.064544 42.28787)', crs = 4326)
#> Geometry set for 1 feature #> geometry type: POINT #> dimension: XY #> bbox: xmin: -71.06454 ymin: 42.28787 xmax: -71.06454 ymax: 42.28787 #> epsg (SRID): 4326 #> proj4string: +proj=longlat +datum=WGS84 +no_defs
#> POINT (-71.06454 42.28787)