to_sf | R Documentation |
This function convers the popgraph object into an object that can be plot using the leaflet library.
to_sf( x, what = c("nodes", "edges")[1], Longitude = "Longitude", Latitude = "Latitude", CRS = 4326 )
x |
A population graph |
what |
An indication of either |
Longitude |
The name of the column with the longitude (or equivalent) coordinates |
Latitude |
The name of the column with the latitude (or equivalent) coordinate. |
CRS |
The coordinate reference system (see https://epsg.io for values). |
A data.frame
object suitable for passing to leaflet
.
Rodney J. Dyer <rjdyer@vcu.edu>
# library(igraph) # data(lopho) # data(baja) # graph <- decorate_graph(lopho, baja ) # nodes <- to_sf( graph, what="nodes") # edges <- to_sf( graph, what="edges") # library( leaflet ) # leaflet() %>% # addTiles() %>% # addMarkers( data=nodes ) %>% # addPolylines( data=edges )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.