to_sf: This function convers the popgraph object into an object that...

View source: R/to_sf.R

to_sfR Documentation

This function convers the popgraph object into an object that can be plot using the leaflet library.

Description

This function convers the popgraph object into an object that can be plot using the leaflet library.

Usage

to_sf(
  x,
  what = c("nodes", "edges")[1],
  Longitude = "Longitude",
  Latitude = "Latitude",
  CRS = 4326
)

Arguments

x

A population graph

what

An indication of either node or edge objects to be returned for plotting on a leaflet object.

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).

Value

A data.frame object suitable for passing to leaflet.

Author(s)

Rodney J. Dyer <rjdyer@vcu.edu>

Examples

# 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 )

dyerlab/popgraph documentation built on July 22, 2022, 5:42 p.m.