Coordinate reference system is always WGS84 in accordance with GeoJSON RFC.
Arguments
- x
sfobject. Supportssforsfc- opts
named list of options. Usually created with
opts_write_geojson(). Default: emptylist()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 withopts_write_json(). Default value is an emptylist()which means to use all the default JSON writing options which is usually the correct thing to do when writing GeoJSON.- filename
filename
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)))
#> {
#> "type": "FeatureCollection",
#> "features": [
#> {
#> "type": "Feature",
#> "properties": {
#> "prop0": "value0",
#> "prop1": null
#> },
#> "geometry": {
#> "type": "Point",
#> "coordinates": [
#> 102.0,
#> 0.5
#> ]
#> }
#> },
#> {
#> "type": "Feature",
#> "properties": {
#> "prop0": "value0",
#> "prop1": "0.000000"
#> },
#> "geometry": {
#> "type": "LineString",
#> "coordinates": [
#> [
#> 102.0,
#> 0.0
#> ],
#> [
#> 103.0,
#> 1.0
#> ],
#> [
#> 104.0,
#> 0.0
#> ],
#> [
#> 105.0,
#> 1.0
#> ]
#> ]
#> }
#> },
#> {
#> "type": "Feature",
#> "properties": {
#> "prop0": "value0",
#> "prop1": "{\"this\":\"that\"}"
#> },
#> "geometry": {
#> "type": "Polygon",
#> "coordinates": [
#> [
#> [
#> 100.0,
#> 0.0
#> ],
#> [
#> 101.0,
#> 0.0
#> ],
#> [
#> 101.0,
#> 1.0
#> ],
#> [
#> 100.0,
#> 1.0
#> ],
#> [
#> 100.0,
#> 0.0
#> ]
#> ]
#> ]
#> }
#> }
#> ]
#> }
