write_geojson: Functions to write GeoJSON files with usage analogous to...

View source: R/write_geojson.R

write_geojsonR Documentation

Functions to write GeoJSON files with usage analogous to write.table.

Description

write_geojson_js is a simple extension which adds a var to the GeoJSON string so leaflet and other JavaScript libraries can assign the objects easily.

Usage

write_geojson(sp, file, pretty = TRUE, round = NA)

write_geojson_js(sp, file, name = NA, pretty = TRUE, round = NA)

Arguments

sp

Spatial object to be written as GeoJSON file.

file

File name of GeoJSON file.

pretty

Format the JSON for readability.

round

How many decimal points should the coordinate pairs be exported with? Default is maximum but 6 is common for spatial data.

name

Name of JavaScript object (only used in write_geojson_js).

Author(s)

Stuart K. Grange

Examples

## Not run: 

# Export spatial object as GeoJSON file
write_geojson(sp_thames_locks, "thames_locks.json", pretty = TRUE)

# Export spatial object as GeoJSON file ready for leaflet
write_geojson(sp_thames_locks, "thames_locks.js", name = "data_locks")


## End(Not run)


skgrange/gissr documentation built on June 20, 2024, 12:02 a.m.