|
1 | 1 | # mapR
|
2 |
| - 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. |
3 |
| - |
| 2 | + |
| 3 | +## Description |
| 4 | +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. |
| 5 | + |
| 6 | +## Install |
| 7 | +To install the package you can use `devtools`. You also need to install `rleafmap`. |
| 8 | + |
| 9 | + devtools::install_github("fkeck/rleafmap") |
| 10 | + devtools::install_github("Hackout2/mapR") |
| 11 | + |
| 12 | +## Demo |
| 13 | +First, load the package and the cholera dataset. |
| 14 | + |
| 15 | + library(mapR) |
| 16 | + data(cholera) |
| 17 | + |
| 18 | +The package provides a collection of simple `*Map` functions to easily get interactive maps. |
| 19 | + |
| 20 | +For example, 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. |
| 21 | + |
| 22 | + quickMap(cholera$deaths, col.by="Count", size.by="Count") |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +You can use the `heatMap` function to get an heat map (raster image and/or contour lines) from a `SpatialGridDataFrame`. |
| 28 | + |
| 29 | + heatMap(cholera$deaths.den) |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +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. |
| 34 | + |
| 35 | + pump.adj <- as.matrix(dist(coordinates(cholera$pumps))) |
| 36 | + pump.graph <- graph.adjacency(pump.adj < 0.003, diag = FALSE) |
| 37 | + V(pump.graph)$lat <- coordinates(cholera$pumps)[, 2] |
| 38 | + V(pump.graph)$lon <- coordinates(cholera$pumps)[, 1] |
| 39 | + netMap(pump.graph, v.size=5, width=500, height=300) |
| 40 | + |
| 41 | + |
0 commit comments