evolMap
The evolMap
package provides an easy and flexible way to
create interactive, time-evolving maps from spatial
data in R. It is particularly useful for visualizing historical changes,
events over time, or evolving geospatial datasets, using
Leaflet as the underlying engine. Key features
include:
sf
and GeoJSON for spatial dataThis vignette demonstrates how to use evolMap
to:
The evolMap
package represents and manages information
from a database on an interactive geographic map. It also allows you to
view the evolution of added elements over time or through periods.
Components:
Read geojson
# Source: https://github.com/scriptorivm/pompeii
domi <- st_read('https://raw.githubusercontent.com/scriptorivm/pompeii/master/geojson/domi.geojson')
domi[["info"]] <- paste0("<iframe src=\"",sub("http:","https:",domi[["N3"]]),"\"></iframe>")
domi[is.na(domi[["N3"]]),"info"] <- "Missing info"
Map creation and add information of geojson
You can specify initial coordinates and zoom level in
create_map
function
map <- create_map(center=c(40.750556,14.489722), zoom=16)
map <- add_entities(map,domi,info="info")
plot(map, directory = "pompeii")
## The graph has been generated in the "C:\Users\modes\AppData\Local\Temp\RtmpmaZawI\Rbuild62784ddf762d\evolMap\vignettes\pompeii" path.
# https://leaflet-extras.github.io/leaflet-providers/preview/
map <- create_map(center=c(40.750556,14.489722), zoom=16, provider="OpenStreetMap.HOT")
map <- add_entities(map,domi,info="info")
plot(map, directory = "pompeii_provider")
## The graph has been generated in the "C:\Users\modes\AppData\Local\Temp\RtmpmaZawI\Rbuild62784ddf762d\evolMap\vignettes\pompeii_provider" path.
# Source: https://ukraine.bellingcat.com/
data <- read.csv(system.file("extdata", "ukr-civharm-2023-02-27.csv",
package="evolMap"))
data[["date"]] <- as.Date(data[["date"]],"%m/%d/%Y")
data[["type"]] <- NA
for(i in seq_len(nrow(data))){
if(data[i,"associations"]!=""){
data[i,"type"] <- unlist(strsplit(unlist(strsplit(data[i,"associations"],","))[1],"="))[2]
}
}
map <- create_map(center=c(49.3402,31.9146),zoom=6.75)
map <- add_markers(map, data, color = "type",
latitude = "latitude", longitude = "longitude",
start = "date")
plot(map, dir="ukraine")
## The graph has been generated in the "C:\Users\modes\AppData\Local\Temp\RtmpmaZawI\Rbuild62784ddf762d\evolMap\vignettes\ukraine" path.
mode = 2
map <- create_map(center=c(49.3402,31.9146),zoom=6.75, mode=2)
map <- add_markers(map, data, color = "type",
latitude = "latitude", longitude = "longitude",
start = "date")
plot(map, dir="ukraineNew")
## The graph has been generated in the "C:\Users\modes\AppData\Local\Temp\RtmpmaZawI\Rbuild62784ddf762d\evolMap\vignettes\ukraineNew" path.
The evolMap
package enables: