Skip to content

Commit 25c91a6

Browse files
committed
Add igraph and sp loading in the example of netMap
1 parent b53d6e6 commit 25c91a6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ You can use the `heatMap` function to get an heat map (raster image and/or conto
3636
#### netMap
3737
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.
3838

39+
library(igraph)
40+
library(sp)
41+
3942
pump.adj <- as.matrix(dist(coordinates(cholera$pumps)))
4043
pump.graph <- graph.adjacency(pump.adj < 0.003, diag = FALSE)
4144
V(pump.graph)$lat <- coordinates(cholera$pumps)[, 2]
4245
V(pump.graph)$lon <- coordinates(cholera$pumps)[, 1]
46+
4347
netMap(pump.graph, v.size=5, width=500, height=300)
4448

4549
![netmap](https://cloud.githubusercontent.com/assets/9269625/7374270/854e9046-edd1-11e4-956d-f9e7c6e63696.png)

0 commit comments

Comments
 (0)