#The Meuse data set is loaded using a demo script in package `sp`,
library(sp)
demo(meuse, ask = FALSE, echo = FALSE) # loads the meuse data sets
class(meuse)
## [1] "SpatialPointsDataFrame"
## attr(,"package")
## [1] "sp"
crs.longlat = CRS("+init=epsg:4326")
meuse.longlat = spTransform(meuse, crs.longlat)
library(rgdal)
#The North Carolina SIDS (sudden infant death syndrome) data set
#is available from package `maptools`, and is loaded by
nc <- readOGR(system.file("shapes/", package="maptools"), "sids")
## OGR data source with driver: ESRI Shapefile
## Source: "C:/user/home/loecherm/Documents/R/win-library/3.3/maptools/shapes", layer: "sids"
## with 100 features
## It has 14 fields
## Integer64 fields read as strings: CNTY_ CNTY_ID FIPSNO
proj4string(nc) <- CRS("+proj=longlat +datum=NAD27")
OFFLINE=FALSE # use previously downloaded maps/data
set.seed(123)
R packages leaflet and mapview provide interactive, browser-based maps building upon the leaflet javascript library. Example with points, grid and polygons follow:
library(mapview)
mapview(meuse, zcol = c("zinc"), legend = TRUE)
mapview(nc, zcol = c("SID74"), alpha.regions = 1.0, legend = TRUE)
m1 <- mapview(meuse, zcol = "soil", burst = TRUE, legend = TRUE)
m2 <- mapview(meuse, zcol = "lead", legend = TRUE)
m3 <- mapview(meuse, zcol = "landuse", map.types = "Esri.WorldImagery", legend = TRUE)
m4 <- mapview(meuse, zcol = "dist.m", legend = TRUE)
sync(m1, m2, m3, m4) # 4 panels synchronised
# latticeView(m1, m2, m3, m4) # 4 panels