geojsonio
creates geojson from various inputs - and can easily feed into tools for making maps with geojson data.
library('sp')
poly1 <- Polygons(list(Polygon(cbind(c(-100,-90,-85,-100),
c(40,50,45,40)))), "1")
poly2 <- Polygons(list(Polygon(cbind(c(-90,-80,-75,-90),
c(30,40,35,30)))), "2")
sp_poly <- SpatialPolygons(list(poly1, poly2), 1:2)
json <- geojson_json(sp_poly)
leaflet() %>%
addProviderTiles("Stamen.Toner") %>%
setView(lng = -90, lat = 41, zoom = 4) %>%
addGeoJSON(json)
data.frame
Also, can do so from data.frames with polygons, lists, matrices, vectors, and json strings
SpatialPoints
classSpatialPixelsDataFrame
classlibrary("sp")
pixelsdf <- suppressWarnings(
SpatialPixelsDataFrame(points = canada_cities[c("long", "lat")], data = canada_cities)
)
map_gist(pixelsdf)
Many other spatial classes supported