Convert data to WKT
Arguments
- x
Output from
mr_geojson()
,mr_shp()
, or aSpatialPolygonsDataFrame
- fmt
(integer) The number of digits to display after the decimal point when formatting coordinates. Ignored when shp files or
SpatialPolygonsDataFrame
passed in- ...
Further args passed on to
jsonlite::fromJSON()
only in the event of json passed as a character string. Ignored when shp files orSpatialPolygonsDataFrame
passed in
Details
WKT, or Well Known Text, is a way to encode spatial data. It's
somewhat similar to GeoJSON, but instead of being in JSON format, it's a
character string (though can also be encoded in binary format). WKT is
often used in SQL databases, and many species occurrence APIs allow only
WKT. You could do the conversion to WKT yourself, but we provide
as_wkt
as a convenience
Examples
if (FALSE) {
res <- mr_geojson(key = "Morocco:dam")
mr_as_wkt(res)
# shp files
## path to wkt
mr_as_wkt(mr_shp(key = "Morocco:dam", read = FALSE))
## spatial object to wkt
mr_as_wkt(mr_shp(key = "Morocco:dam", read = TRUE))
}