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/2builds aNetworkex.Networkfrom the line geometries of aGeoFrame.GeoDataFrameorGeoFrame.GeoSeries;snap/2snaps the centroids of a frame's geometries (points are their own centroid);arcs/2,points/2andpaths/2turn networks, point patterns and shortest paths back intoGeoFrame.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
@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:
:columns- a map of extra columns, each a list with one value per arc (or edge), such asNetworkex.Network.counts_per_link/3;:crs- the CRS of the result.
@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.
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.
@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.
@spec snap(Networkex.Network.t(), struct()) :: Networkex.PointPattern.t()
Snaps the centroids of the geometries of a GeoFrame.GeoDataFrame or GeoFrame.GeoSeries to
the network (Networkex.Network.snap/2).