Convert various data formats to GeoJSON or TopoJSON
This package is a utility to convert geographic data to GeoJSON and TopoJSON formats. Nothing else. We hope to do this one job very well, and handle all reasonable use cases.
Functions in this package are organized first around what you're working with or want to get, GeoJSON or TopoJSON, then convert to or read from various formats:
geojson_list()
/topojson_list()
- convert to GeoJSON/TopoJSON as R list formatgeojson_json()
/topojson_json()
- convert to GeoJSON/TopoJSON as JSONgeojson_sp()
- convert output ofgeojson_list()
orgeojson_json()
tosp
spatial objectsgeojson_sf()
- convert output ofgeojson_list()
orgeojson_json()
tosf
objectsgeojson_read()
/topojson_read()
- read a GeoJSON/TopoJSON file from file path or URLgeojson_write()
/topojson_write()
- write a GeoJSON/TopoJSON file locally
Each of the above functions have methods for various objects/classes, including numeric
, data.frame
, list
, SpatialPolygons
, SpatialLines
, SpatialPoints
, etc.
Additional functions:
map_gist()
- push up a GeoJSON or topojson file as a GitHub gist (renders as an interactive map)map_leaf()
- create a local interactive map using theleaflet
package
- GeoJSON - spec
- GeoJSON lint
- TopoJSON - spec
A note about installing rgeos
- built on top of C libraries, and installation often causes trouble for Linux users because no binaries are provided on CRAN for those platforms. Other dependencies in geojsonio
should install easily automatically when you install geojsonio
.
Mac
Install GDAL
on the command line first, e.g., using homebrew
brew install gdal
Then install rgeos
install.packages("rgeos", type = "source")
Linux
Get deps first
sudo apt-get install libgdal1-dev libgdal-dev libgeos-c1 libproj-dev
Note: if you have trouble installing rgeos, try installing
libgeos++-dev
Then install rgeos
install.packages("rgeos", type = "source")
Install geojsonio
Stable version from CRAN
install.packages("geojsonio")
Or development version from GitHub
install.packages("remotes")
remotes::install_github("ropensci/geojsonio")
library("geojsonio")
- Please report any issues or bugs.
- License: MIT
- Get citation information for
geojsonio
in R doingcitation(package = 'geojsonio')
- Please note that this package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.