[R-sig-Geo] how to directly merge JSON data with geoJSON file?
Richard Zijdeman
richard.zijdeman at gmail.com
Fri Oct 3 16:27:12 CEST 2014
Dear list,
I'm trying to add data in json format to a geojson file. I realise that one way of doing this, is to transform the geojson file into a shape file, the data in an R object, and merge the two, as attempted here: http://stackoverflow.com/questions/17181339/r-geojson-and-leaflet . However, I was wondering whether this is possible without switching 'back' to a shape file. Here's the code to obtain the geojson file and data file:
##########################################
library(leafletR)
library(jsonlite)
# obtaining map
download.file("http://node-128.dev.socialhistoryservices.org/api/maps?year=1937",
destfile = paste0("testmap", ".json"))
map <- leaflet("./testmap.json")
map # displays map in browser
# obtaining data
testdata <-
fromJSON("http://node-128.dev.socialhistoryservices.org/api/data?code=TXCU)
##########################################
Note: the 'key' in both files is 'amsterdam_code'
Best wishes,
Richard
ps: I am guilty of cross-posting this message on stack overflow, but I have had no response:http://stackoverflow.com/questions/26109260/how-to-add-json-data-to-geojson-map-without-going-back-to-shape-files
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list