geojsonio: Convert Data from and to 'geoJSON' or 'topoJSON'

geoJSONtopoJSONファイルをデータとして扱う

> library(geojsonio)
Error: package or namespace load failed for 'geojsonio'

バージョン: 0.2.0.9000


関数名 概略
as.json Convert inputs to JSON
as.location Convert a path or URL to a location object.
bounds Get bounds for a list or geo_list
canada_cities This is the same data set from the maps library, named differently
centroid Get centroid for a geo_list
file_to_geojson Convert spatial data files to GeoJSON from various formats.
geojson-add Add together geo_list or json objects
geojson_json Convert many input types with spatial data to
geojson specified as a json string
geojson_list Convert many input types with spatial data to
geojson specified as a list
geojson_read Read geojson from a local file or a URL
geojson_style Style a data.frame or list prior to converting to geojson
geojson_write Convert many input types with spatial data to a geojson file
geojsonio Convert various data formats to/from GeoJSON or TopoJSON
lint Lint geojson
map_gist Publish an interactive map as a GitHub gist
pretty Convert json input to pretty printed output
projections topojson projections and extensions
states This is the same data set from the ggplot2 library
topojson_read Read topojson from a local file or a URL
us_cities This is the same data set from the maps library, named differently
validate Validate a geoJSON file, json object, list, or Spatial class.

as.json

> (res <- geojson_list(us_cities[1:2,], lat = 'lat', lon = 'long'))
Error in eval(expr, envir, enclos): could not find function "geojson_list"
> as.json(res)
Error in eval(expr, envir, enclos): could not find function "as.json"
> as.json(res, pretty = TRUE)
Error in eval(expr, envir, enclos): could not find function "as.json"

centroid

> vec <- c(-99.74,32.45)
> x <- geojson_list(vec)
Error in eval(expr, envir, enclos): could not find function "geojson_list"
> centroid(x)
Error in .pointsToMatrix(x, poly = TRUE): A points matrix should have 2 columns

geojson_json

Arguments

  • input
  • lat
  • lon
  • group
  • geometry... point or polygon
  • type
  • ...
> geojson_json(input = c(32.45, -99.74), geometry = "polygon", pretty = TRUE)
Error in eval(expr, envir, enclos): could not find function "geojson_json"

geojson_write

GeoJSONファイルとして保存

> head(states)
> 
> geojson_write(input = states, 
+               lat = 'lat', lon = 'long', 
+               geometry = 'group', 
+               group    = "group",
+               file     = "filename.geojson")