lair.transects.merge_route_points#

lair.transects.merge_route_points(routes_xy, tol)[source]#

Merge the fixed points of several routes into one network point set.

Points of the first route are kept; a point of a later route is added only if it is farther than tol from every point already in the set, otherwise it is snapped to the nearest existing one. Shared track thus maps to shared network points.

Parameters:
  • routes_xy (list[np.ndarray]) – One (n_i, 2) array of projected coordinates (meters) per route.

  • tol (float) – Distance (meters) within which a point joins an existing network point.

Returns:

tuple[np.ndarray, list[np.ndarray]] – (network_xy, index): the network points, and per route the network point of each of its points (index[i][k] for route i’s point k).

Return type:

tuple[ndarray, list[ndarray]]

See also

pool_routes

Stacks the routes’ matrices onto the network points.

Examples

The second route shares two points with the first (within 50 m) and adds one:

>>> import numpy as np
>>> from lair.transects import merge_route_points
>>> r1 = np.array([[0, 0], [1000, 0], [2000, 0.0]])
>>> r2 = np.array([[1000, 10], [2000, 5], [2000, 1000.0]])
>>> network, index = merge_route_points([r1, r2], tol=50)
>>> network
array([[   0.,    0.],
       [1000.,    0.],
       [2000.,    0.],
       [2000., 1000.]])
>>> index
[array([0, 1, 2]), array([1, 2, 3])]