Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

as_json

Convert geojson R list to JSON


Description

Convert geojson R list to JSON

Usage

as_json(x, pretty = TRUE, auto_unbox = TRUE, ...)

Arguments

x

Output from wkt2geojson()

pretty

(logical) Adds indentation whitespace to JSON output. Can be TRUE/FALSE or a number specifying the number of spaces to indent. See jsonlite::prettify(). Default: TRUE. Having TRUE as default makes it easy to copy paste to a text editor, etc.

auto_unbox

(logical) Automatically unbox all atomic vectors of length 1. Default: TRUE

...

Further args passed on to jsonlite::toJSON()

Examples

str <- "POLYGON ((100 0.1, 101.1 0.3, 101 0.5, 100 0.1),
   (103.2 0.2, 104.8 0.2, 100.8 0.8, 103.2 0.2))"
as_json(wkt2geojson(str))
as_json(wkt2geojson(str), FALSE)

wellknown

Convert Between 'WKT' and 'GeoJSON'

v0.7.2
MIT + file LICENSE
Authors
Scott Chamberlain [aut, cre] (<https://orcid.org/0000-0003-1444-9135>), Os Keyes [aut] (author of code in src/)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.