Learn R Programming

mregions (version 0.1.8)

mr_as_wkt: Convert data to WKT

Description

Convert data to WKT

Usage

mr_as_wkt(x, fmt = 16, ...)

Arguments

x

Output from mr_geojson(), mr_shp(), or a SpatialPolygonsDataFrame

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 or SpatialPolygonsDataFrame passed in

Value

a character string of WKT data

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

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataLab