TransWikia.com

Merging two GeoJSON files for Leaflet Map in R

Geographic Information Systems Asked by Jenali Mehta on June 20, 2021

Does anyone know how to convert 2 GeoJSON files into 1 in R? I’m trying to build a Leaflet map for the two files together.

library(geojsonio)
library(leaflet)

dataset1 <-geojson_read("https://opendata.arcgis.com/datasets/3525b0ee6e6b427f9aab5d0a1d0a1a28_0.geojson", what = "sp")
MassData <- geojson_read("https://raw.githubusercontent.com/NewtonMAGIS/GISData/master/Massachusetts%20Town%20Boundaries/MassTowns.geojson", what = "sp")
dataset2 <- MassData
dataset2 <- subset(MassData, TOWN %in% c("BROOKLINE", "CAMBRIDGE","MEDFORD", "SOMERVILLE"))

merged <- TO_GeoJson(c(dataset1, dataset2))

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP