snap#
module wntr.gis.geospatial
- snap(A, B, tolerance)[source]#
Snap Points in A to Points or Lines in B
For each Point geometry in A, the function returns snapped Point geometry and associated element in B. Note the CRS of A must equal the CRS of B.
- Parameters:
A (geopandas GeoDataFrame) – GeoDataFrame containing Point geometries.
B (geopandas GeoDataFrame) – GeoDataFrame containing Point, LineString, or MultiLineString geometries.
tolerance (float) – Maximum allowable distance (in the coordinate reference system units) between Points in A and Points or Lines in B.
- Returns:
Snapped points (index = A.index, columns = defined below)
- If B contains Points, columns include:
node: closest Point in B to Point in A
snap_distance: distance between Point in A and snapped point
geometry: GeoPandas Point object of the snapped point
- If B contains Lines or MultiLineString, columns include:
link: closest Line in B to Point in A
node: start or end node of Line in B that is closest to the snapped point (if B contains columns “start_node_name” and “end_node_name”)
snap_distance: distance between Point A and snapped point
line_position: normalized distance of snapped point along Line in B from the start node (0.0) and end node (1.0)
geometry: GeoPandas Point object of the snapped point
- Return type:
GeoPandas GeoDataFrame