momepy.COINS#
- class momepy.COINS(edge_gdf, angle_threshold=0, flow_mode=False)[source]#
Calculates natural continuity and hierarchy of street networks in a given GeoDataFrame using the COINS algorithm.
For details on the algorithms refer to the original paper [Tripathy et al., 2020].
This is a reimplementation of the original script from PratyushTripathy/COINS
COINS
can return final stroke geometry (.stroke_gdf()
) or a pandas Series encoding stroke groups onto the original input geometry (.stroke_attribute()
).- Parameters:
- edge_gdfGeoDataFrame
A GeoDataFrame containing edge geometry of a street network.
edge_gdf
cannot contain identical or overlapping LineStrings.edge_gdf
should ideally not contain MultiLineStrings.- angle_thresholdint, float (default 0), units: degrees
The threshold for the interior angle within the COINS algorithm. Possible values:
0 <= angle_threshold < 180
, in degrees. Segments will only be considered part of the same stroke group if the interior angle between them is above the threshold.- flow_modebool, default False
Continuity can be derived based on either visibility (
flow_mode=False
) or flow (flow_mode=True
). In the former case, a stroke group break is created at any angle above theangle_threshold
, even at internal nodes within the LineString (so one LineString can be divided into multiple stroke groups if its segments connect at an angle aboveangle_threshold
). This corresponds to visibility-based continuity. In the latter case, stroke group breaks are only created at the end points of LineStrings, following the “flow” definition of continuity where the direction of flow can change only at intersections. This also ensures that each LineString can be assigned only a single stroke group. Note that this option is not covered by [Tripathy et al., 2020].
Methods
stroke_attribute
([return_ends])Return a pandas Series encoding stroke groups onto the original input geometry.
stroke_gdf
()Return a GeoDataFrame containing merged final stroke geometry.
Notes
The LineStrings of the
edge_gdf
are not expected to overlap. If you are creating it using OSMnx, don’t forget to cast the graph to undirected usingosmnx.convert.to_undirected(G)
prior converting it to a GeoDataFrame.Examples
Initialise a
COINS
class. This step will compute the topology.>>> coins = momepy.COINS(streets)
To get final stroke geometry:
>>> stroke_gdf = coins.stroke_gdf()
To get a Series encoding stroke groups:
>>> stroke_attr = coins.stroke_attribute()
Methods
__init__
(edge_gdf[, angle_threshold, flow_mode])stroke_attribute
([return_ends])Return a pandas Series encoding stroke groups onto the original input geometry.
stroke_gdf
()Return a GeoDataFrame containing merged final stroke geometry.