mr_as_wkt: Convert data to WKT

Description Usage Arguments Details Value Examples

View source: R/as_wkt.R

Description

Convert data to WKT

Usage

1
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 fromJSON only in the event of json passed as a character string. Ignored when shp files or SpatialPolygonsDataFrame 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

Value

a character string of WKT data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
res <- mr_geojson(key = "Morocco:dam")
mr_as_wkt(res, fmt = 5)

# 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))

## End(Not run)

mregions documentation built on May 2, 2019, 6:53 a.m.