Networkex.GeoFrame (Networkex v0.3.0)

Copy Markdown View Source

Adapter between GeoFrame, a library of geospatial data frames, and Networkex.

Networkex does not depend on GeoFrame. This module calls GeoFrame's public API (and Explorer's, which GeoFrame brings) at runtime, and raises an ArgumentError saying so when GeoFrame is not loaded. Add {:geoframe, "~> 0.3.4"} to your own dependencies to use it.

  • network/2 builds a Networkex.Network from the line geometries of a GeoFrame.GeoDataFrame or GeoFrame.GeoSeries;
  • snap/2 snaps the centroids of a frame's geometries (points are their own centroid);
  • arcs/2, points/2 and paths/2 turn networks, point patterns and shortest paths back into GeoFrame.GeoDataFrames, for maps (GeoFrame.Kino.deck/2) and further GeoFrame work.

Geographic coordinates

Network lengths are Euclidean, so on longitude/latitude they measure degrees. network/2 raises ArgumentError for a geographic CRS unless allow_geographic: true; project the frame first (GeoFrame.GeoDataFrame.to_crs/2).

Examples

streets = GeoFrame.read_file!("streets.shp")
ntw = Networkex.GeoFrame.network(streets)
crimes = Networkex.GeoFrame.snap(ntw, GeoFrame.read_file!("crimes.shp"))
Networkex.GeoFrame.arcs(ntw, columns: %{"crimes" => Networkex.Network.counts_per_link(ntw, crimes)})

Summary

Functions

The arcs of the network as a GeoFrame.GeoDataFrame of two-point lines with the columns "arc" (index), "i", "j" (vertex ids) and "length". With graph: true, the graph edges instead (straight lines between their end vertices). Options

A network from the line geometries (LineString or MultiLineString) of a GeoFrame.GeoDataFrame or GeoFrame.GeoSeries. Options of Networkex.Network.new/2, plus allow_geographic: true to accept longitude/latitude.

Shortest paths (Networkex.Network.shortest_paths/3) as a GeoFrame.GeoDataFrame of lines with the columns "source", "dest" and "length"; :crs as in arcs/2.

A point pattern as a GeoFrame.GeoDataFrame of points: the snapped points (default) or, with which: :observed, the observations as given; with the columns "i", "j" (the arc) and "snap_distance", plus :columns and :crs as in arcs/2.

Snaps the centroids of the geometries of a GeoFrame.GeoDataFrame or GeoFrame.GeoSeries to the network (Networkex.Network.snap/2).

Functions

arcs(ntw, opts \\ [])

@spec arcs(Networkex.Network.t(), keyword()) :: struct()

The arcs of the network as a GeoFrame.GeoDataFrame of two-point lines with the columns "arc" (index), "i", "j" (vertex ids) and "length". With graph: true, the graph edges instead (straight lines between their end vertices). Options:

network(frame, opts \\ [])

@spec network(struct(), keyword()) :: Networkex.Network.t()

A network from the line geometries (LineString or MultiLineString) of a GeoFrame.GeoDataFrame or GeoFrame.GeoSeries. Options of Networkex.Network.new/2, plus allow_geographic: true to accept longitude/latitude.

paths(paths, opts \\ [])

@spec paths([map()], keyword()) :: struct()

Shortest paths (Networkex.Network.shortest_paths/3) as a GeoFrame.GeoDataFrame of lines with the columns "source", "dest" and "length"; :crs as in arcs/2.

points(pp, opts \\ [])

@spec points(Networkex.PointPattern.t(), keyword()) :: struct()

A point pattern as a GeoFrame.GeoDataFrame of points: the snapped points (default) or, with which: :observed, the observations as given; with the columns "i", "j" (the arc) and "snap_distance", plus :columns and :crs as in arcs/2.

snap(ntw, frame)

Snaps the centroids of the geometries of a GeoFrame.GeoDataFrame or GeoFrame.GeoSeries to the network (Networkex.Network.snap/2).