Type: Package
Title: Geographic Networks
Version: 0.6.0
Encoding: UTF-8
Description: Provides classes and methods for handling networks or graphs whose nodes are geographical (i.e. locations in the globe). The functionality includes the creation of objects of class geonetwork as a graph with node coordinates, the computation of network measures, the support of spatial operations (projection to different Coordinate Reference Systems, handling of bounding boxes, etc.) and the plotting of the geonetwork object combined with supplementary cartography for spatial representation.
Depends: R (≥ 3.5)
License: GPL-3 | file LICENSE
Language: en-GB
LazyData: true
Imports: geosphere, igraph, sf
Suggests: devtools, knitr, maps, mapview, rmarkdown, roxygen2, spData, testthat (≥ 3.0.0), tmaptools
RoxygenNote: 7.3.2
URL: https://astre.gitlab.cirad.fr/geonetwork, https://gitlab.cirad.fr/astre/geonetwork
BugReports: https://gitlab.cirad.fr/astre/geonetwork/-/issues
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2025-07-23 10:12:13 UTC; facu
Author: Facundo Muñoz ORCID iD [aut, cre]
Maintainer: Facundo Muñoz <facundo.munoz@cirad.fr>
Repository: CRAN
Date/Publication: 2025-07-23 10:40:02 UTC

Distances between 21 European cities

Description

A geonetwork object representing a full graph of 21 European cities with edges weighted by distance in km.

Usage

eurodist

Format

geonetwork.

Source

Distances (in km) between 21 European cities are taken from eurodist. Coordinates of the cities were obtained with geocode_OSM.


Create geographic networks

Description

Create an igraph object with geospatial attributes for the nodes.

Usage

geonetwork(edges, nodes, directed = TRUE, CRS = 4326)

Arguments

edges

data.frame. Edges list and attributes. See Details.

nodes

data.frame. Nodes list and attributes. See Details.

directed

logical. Default is to build a directed graph.

CRS

Coordinate Reference System, as a numeric or character code, an object of class [sf::sf] or [sf::sfc], or a 'src' object as built by function [sf::st_crs].

Details

The first two columns in edges must be character or factor, and match the node names in the first column of the nodes data.frame. The third column, if any, will be used as edge weights. The remaining columns will be used as additional edge attributes.

The first column in nodes must be character or factor and provide node names or labels, not necessarily unique. Columns 2 and 3 must be numeric coordinates in the Coordinate Reference System specified in CRS.

Value

An object of class geonetwork, which also inherits from igraph.

Examples

  e <- data.frame(from = c("A", "A"), to = c("B", "C"))
  n <- data.frame(id = LETTERS[1:3], x = c(0, 0, 1), y = c(0, 1, 0))
  geonetwork(e, n)

Plot a geonetwork

Description

Plot one or more attributes of a geonetwork on a map

Usage

## S3 method for class 'geonetwork'
plot(x, y, ...)

Arguments

x

Object of class geonetwork.

y

Ignored.

...

Further specifications passed to plot_sf.

Examples

plot(eurodist, axes = TRUE, type = "n")
plot(sf::st_geometry(spData::world), col = "lightgray", add = TRUE)
plot(eurodist, axes = TRUE, add = TRUE)