write_geojson_str {yyjsonr}R Documentation

Write SF to GeoJSON string

Description

Write SF to GeoJSON string

Usage

write_geojson_str(x, opts = list(), ..., json_opts = list())

write_geojson_file(x, filename, opts = list(), ..., json_opts = list())

Arguments

x

sf object. Supports sf or sfc

opts

named list of options. Usually created with opts_write_geojson(). Default: empty list() to use the default options.

...

any extra named options override those in opts

json_opts

Named list of vanilla JSON options as used by write_json_str(). This is usually created with opts_write_json(). Default value is an empty list() which means to use all the default JSON writing options which is usually the correct thing to do when writing GeoJSON.

filename

filename

Value

Character string containing GeoJSON, or NULL if GeoJSON written to file.

Examples

geojson_file <- system.file("geojson-example.json", package = 'yyjsonr')
sf <- read_geojson_file(geojson_file)
cat(write_geojson_str(sf, json_opts = opts_write_json(pretty = TRUE)))

[Package yyjsonr version 0.1.20 Index]