A set of functions to quickly and easily create interactive maps based on Leaflet. Designed to work with mapData
via sp
objects. Also implements some functions to convert more complex objects (like contourlines, graphs, ...) into sp
object.
To install the package you can use devtools
. You also need to install rleafmap
.
devtools::install_github("fkeck/rleafmap")
devtools::install_github("Hackout2/epimap")
First, load the package and the cholera dataset.
library(epimap)
data(cholera)
The package provides a collection of simple *Map
functions to easily get interactive maps.
You can use quickMap
to quickly represent points and polygons and set colors and sizes using a column of the dataframe linked to the sp
object.
quickMap(cholera$deaths, col.by="Count", size.by="Count")
You can use the heatMap
function to get an heat map (raster image and/or contour lines) from a SpatialGridDataFrame
.
heatMap(cholera$deaths.den)
You can use netMap
to map spatial networks from an igraph
object. For example we can create a network of pumps in Snow's London by connecting pumps which are geographically close. Note that you need to set explicitly geographical coordinates to the graph vertices with the lat
and lon
attributes.
library(igraph)
library(sp)
pump.adj <- as.matrix(dist(coordinates(cholera$pumps)))
pump.graph <- graph.adjacency(pump.adj < 0.003, diag = FALSE)
V(pump.graph)$lat <- coordinates(cholera$pumps)[, 2]
V(pump.graph)$lon <- coordinates(cholera$pumps)[, 1]
netMap(pump.graph, v.size=5, width=500, height=300)