linref.ext

linref.ext.base

class linref.ext.base.LRS_Accessor(df)[source]

Bases: object

Accessor for working with linear referencing systems (LRS) in GeoDataFrames.

property df: DataFrame

Return the underlying DataFrame.

property event_cols: list[str]

Return a list of all event-defining columns in the dataframe, including key and measure columns as defined in the LRS.

property measure_cols: list[str]

Return a list of all measure columns in the dataframe as defined in the LRS (i.e., location, begin, and end columns).

property lrs_cols: list[str]

Return a list of all LRS-managed columns in the dataframe, including key, measure, and geometry columns as defined in the LRS.

property other_cols: list[str]

Return a list of all non-LRS-managed columns in the dataframe.

property geometry_sync: str

The geometry synchronization behavior for this DataFrame. State is stored in df.attrs for pandas >= 3.0 compatibility.

property lrs: LRS

The LRS object currently set for the DataFrame. State is stored in df.attrs for pandas >= 3.0 compatibility.

property is_lrs_set: bool

Whether an LRS object is currently set for the DataFrame.

property is_lrs_empty: bool

Whether the currently set LRS object is empty (i.e., has no key, measure, or geometry columns defined).

property key_col: list[str]

Return a list of all event key columns in the set LRS if defined, including the chain column when it exists in the DataFrame.

property base_key_col: list[str]

Return the base key columns from the LRS definition, excluding the chain column. Used for operations that need to group by route identifiers without chaining (e.g., computing chain indices).

property loc_col: str

Return the location measure column in the set LRS if defined.

property beg_col: str

Return the begin measure column in the set LRS if defined.

property end_col: str

Return the end measure column in the set LRS if defined.

property geom_col: str

Return the geometry column in the set LRS if defined.

property geom_m_col: str

Return the M-enabled geometry column in the set LRS if defined.

property closed: str

Return the closure type in the set LRS if defined.

property index: ndarray

Return the index values of the dataframe. Equivalent to self.df.index.values.

property keys: ndarray

Return the event keys from the dataframe as an array.

property locs: ndarray

Return the location measure values from the dataframe as an array. If no location column is defined in the LRS, returns None.

property begs: ndarray

Return the begin measure values from the dataframe as an array. If no begin column is defined in the LRS, returns None.

property ends: ndarray

Return the end measure values from the dataframe as an array. If no end column is defined in the LRS, returns None.

property event_lengths: ndarray

Return the event lengths from the dataframe as an array. If no begin and end columns are defined in the LRS, returns None.

property geoms: ndarray

Return the geometry values from the dataframe as an array. If no geometry column is defined in the LRS, returns None.

property geoms_m: ndarray

Return the M-enabled geometry values from the dataframe as an array. If no M-enabled geometry column is defined in the LRS, returns None.

property geoms_m_reduced: ndarray

Extract and return the shapely geometries from the M-enabled geometry column in the dataframe.

property is_grouped: bool

Return whether the active LRS is grouped and the key columns are present in the dataframe.

property missing_key_cols: list[str]

Return a list of key columns defined in the LRS but missing from the DataFrame. Returns an empty list if no keys are defined or all keys are present.

property is_linear: bool

Return whether the active LRS is linear and the begin and end columns are present in the dataframe.

property is_point: bool

Return whether the active LRS is point-based and the location column is present in the dataframe.

property is_located: bool

Return whether the active LRS is located and the location column is present in the dataframe.

property is_spatial: bool

Return whether the active LRS is spatial and the geometry column is present in the dataframe.

property is_spatial_m: bool

Return whether the active LRS is spatial and the geometry column is present in the dataframe.

property is_lrs_grouped: bool

Return whether the active LRS is grouped, regardless of presence of key columns in the dataframe.

property is_lrs_linear: bool

Return whether the active LRS is linear, regardless of presence of begin and end columns in the dataframe.

property is_lrs_point: bool

Return whether the active LRS is point-based, regardless of presence of location column in the dataframe.

property is_lrs_located: bool

Return whether the active LRS is located, regardless of presence of location column in the dataframe.

property is_lrs_spatial: bool

Return whether the active LRS is spatial, regardless of presence of geometry column in the dataframe.

property is_lrs_spatial_m: bool

Return whether the active LRS is spatial with M values, regardless of presence of geometry column in the dataframe.

property is_lrs_chained: bool

Return whether the active LRS has a chain column defined, regardless of presence of the chain column in the dataframe.

property is_chained: bool

Return whether the active LRS has a chain column defined and the chain column is present in the dataframe.

property is_geometrically_contiguous: bool

Return whether linear geometries in the dataframe when grouped by LRS keys are geometrically contiguous, producing single continuous geometries without gaps when dissolved and merged.

property is_contiguous: bool

Return whether linear geometries in the dataframe when grouped by LRS keys are contiguous, producing continuous geometries without disjoints such as overlaps or gaps.

property is_disjointed: bool

Return whether linear geometries in the dataframe when grouped by LRS keys contain disjointed segments (i.e., are not contiguous). Equivalent to not self.is_contiguous.

property valid_events: Series

Return a boolean Series indicating which events in the dataframe are valid according to the active LRS, e.g., have populated key columns and event measures.

property invalid_events: Series

Return a boolean Series indicating which events in the dataframe are invalid according to the active LRS, e.g., have missing key columns or event measures.

drop_invalid_events() DataFrame | None[source]

Drop invalid events from the dataframe according to the active LRS. Invalid events are those with missing data in key columns or event measures.

Returns:

df – A copy of the DataFrame with invalid events removed.

Return type:

DataFrame

study() dict[source]

Evaluate which LRS properties are satisfied by the dataframe.

property events: EventsData

Return the events object for the active LRS.

check_exact_geoms(if_missing: bool = True) ndarray[source]

Check if geometries in both the geometry and geometry_m columns are exactly the same, returning an array of boolean values.

Parameters:

if_missing (bool, default True) – The value to return for rows where either geometry column is missing.

get_keys(col=None, require=True) ndarray[source]

Return the event keys from the dataframe as an array.

Parameters:
  • col (str, optional) – The column name to use for extracting keys. If None, uses the default key columns in the LRS.

  • require (bool, default True) – Whether to raise an error if the key column is not found.

Returns:

An array of event keys.

Return type:

np.ndarray

get_events(key_col=None, require=True, allow_undefined_events=False) EventsData[source]

Return the events object for the active LRS.

Parameters:
  • key_col (str, optional) – The column name to use for extracting keys. If None, uses the default key columns in the LRS.

  • require (bool, default True) – Whether to raise an error if the key column is not found.

  • allow_undefined_events (bool, default False) – Whether to allow undefined events when creating the EventsData object. If False, will raise an error if undefined events are present. Undefined events are those with no defined location, begin, or end values.

copy(deep: bool = False) LRS_Accessor[source]

Create an exact copy of the object instance.

Parameters:

deep (bool, default False) – Whether the created copy should be a deep copy.

copy_df() DataFrame[source]

Create a copy of the underlying DataFrame, preserving LRS settings.

lrs_like(other: DataFrame | LRS_Accessor, inplace: bool = False) DataFrame | None[source]

Assign the LRS settings of another DataFrame to the current DataFrame.

Parameters:
  • other (DataFrame or LRS_Accessor) – The DataFrame or LRS_Accessor to copy LRS settings from.

  • inplace (bool, default False) – Whether to apply changes to the DataFrame in place.

Returns:

df – A copy of the current DataFrame with LRS settings copied from the input DataFrame.

Return type:

DataFrame

set_lrs(lrs: LRS | None = None, inplace: bool = False, **kwargs) DataFrame | None[source]

Set the LRS object for the DataFrame.

Parameters:
  • lrs (LRS , default None) – The LRS object to set for the DataFrame.

  • inplace (bool, default False) – Whether to apply changes to the DataFrame in place.

  • **kwargs – Additional parameters to set for the LRS object if lrs is None.

modify_lrs(inplace: bool = False, **kwargs) DataFrame | None[source]

Modify the parameters of the existing LRS object in the DataFrame.

Parameters:
  • **kwargs – The LRS parameters from an LRS object to modify.

  • inplace (bool, default False) – Whether to apply changes to the DataFrame in place. Note, this does not modify the existing LRS object in place, but creates a modified copy of the existing LRS object and sets it to the DataFrame. To modify the LRS object itself, access the LRS object directly via df.lr.lrs.

add_key(key_col: str | list[str], inplace: bool = False) DataFrame | None[source]

Add one or more key columns to an existing LRS object in the DataFrame.

Parameters:
  • key_col (label or array-like) – The key column or array-like of key columns to add.

  • inplace (bool, default False) – Whether to apply changes to the DataFrame in place.

remove_key(key_col: str | list[str], errors: str = 'raise', inplace: bool = False) None[source]

Remove one or more key columns from an existing LRS object in the DataFrame.

Parameters:
  • key_col (label or array-like) – The key column or array-like of key columns to remove.

  • errors ({'ignore', 'raise'}, default 'raise') – Whether to raise an error or ignore missing keys.

  • inplace (bool, default False) – Whether to apply changes to the DataFrame in place.

clear_lrs(inplace: bool = False) None[source]

Clear the LRS object from the DataFrame. Applies a new empty LRS object equivalent to LRS().

Parameters:

inplace (bool, default False) – Whether to apply changes to the DataFrame in place.

set_monotonic(*args, **kwargs)
build_geom_m() ndarray[source]

Build a list of geometry_m objects based on the begin and end locations of the LRS.

Returns:

geoms_m – An array of geometry_m objects.

Return type:

np.ndarray

add_geom_m(name: str = 'geometry_m', inplace: bool = False) DataFrame | None[source]

Add an M-enabled geometry column to the DataFrame based on the begin and end values of the LRS.

Parameters:
  • name (str, default 'geometry_m') – The name of the geometry column to return.

  • inplace (bool, default False) – Whether to apply changes to the dataframe in place.

iter_groups(*args, **kwargs)
group_counts(*args, **kwargs)
sort_standard(return_index: bool = False, inplace: bool = False) DataFrame | tuple[DataFrame, ndarray] | None[source]

Sort the dataframe by the LRS columns in the standard order of ‘groups’, ‘begs’, ‘ends’ for linear events and ‘groups’, ‘locs’ for point events.

Parameters:
  • return_index (bool, default False) – Whether to return an array of the indices which represent the performed sort in addition to the sorted events.

  • inplace (bool, default False) – Whether to perform the operation in place, returning None.

get_group(*args, **kwargs)
get_chains(*args, **kwargs)
add_chaining(*args, **kwargs)
point_to_linear(*args, **kwargs)
generate_linear_events(*args, **kwargs)
extend(*args, **kwargs)
shift(*args, **kwargs)
round(*args, **kwargs)
impute_keys(*args, **kwargs)
resegment(*args, **kwargs)
separate(*args, **kwargs)
dissolve(*args, **kwargs)
constrain_to(*args, **kwargs)
split(*args, **kwargs)
clip(*args, **kwargs)
integrate(*args, **kwargs)
cut_from(*args, **kwargs)
interpolate_from(*args, **kwargs)
distribute_from(other: DataFrame, columns: list | str | None = None, inplace: bool = False, replace: bool = False, **params) DataFrame | None[source]

Distribute attribute data from another dataframe onto the current dataframe based on linear referencing relationships. This is a shortcut for lr.relate(other)[columns].distribute(**params).

Parameters:
  • other (DataFrame) – The other DataFrame to distribute attributes from. Must have an equivalent linear referencing system.

  • columns (str or list, optional) – The column label or list of column labels to distribute from the other dataframe. If None, all columns except key and geometry columns will be distributed.

  • inplace (bool, default False) – Whether to apply changes to the DataFrame in place.

  • replace (bool, default False) – Whether to replace existing columns in the DataFrame with the same names as those being distributed. If False, an error will be raised if any column names conflict.

  • **params – Additional parameters to pass to the EventsRelation.distribute method.

Returns:

df – A copy of the current DataFrame with distributed attributes or None if inplace=True.

Return type:

DataFrame

parse_geom_m_wkt(geom_m_col: str | None = None, inplace: bool = False) DataFrame | None[source]

Parse the WKT representation of the M-enabled geometry data into a LineStringM object.

Parameters:
  • geom_m_col (str, optional) – The name of the geometry_m column to parse. If None, use the geometry_m column name from the LRS if present.

  • inplace (bool, default False) – Whether to apply changes to the DataFrame in place.

geom_m_to_wkt(geom_m_col: str | None = None, inplace: bool = False) DataFrame | None[source]

Convert LineStringM objects in the M-enabled geometry column to WKT strings. Typically used for export compatibility while using the linref LineStringM implementation. Will become unnecessary once M- enabled geometries are more widely supported in shapely.

Parameters:
  • geom_m_col (str, optional) – The name of the geometry_m column to convert. If None, use the geometry_m column name from the LRS if present.

  • inplace (bool, default False) – Whether to apply changes to the DataFrame in place.

extract_m_values(beg_col: str | None = None, end_col: str | None = None, replace: bool = False, inplace: bool = False) DataFrame | None[source]

Extract the M values from the geometry_m column, applying them to the begin and end location columns.

Parameters:
  • beg_col (str, optional) – The name of the begin location column to add. If None, uses the existing begin column name in the LRS, or ‘beg’ if no begin column is defined.

  • end_col (str, optional) – The name of the end location column to add. If None, uses the existing end column name in the LRS, or ‘end’ if no end column is defined.

  • replace (bool, default False) – Whether to replace existing begin or end columns in the dataframe. If False, an error will be raised if the columns already exist.

  • inplace (bool, default False) – Whether to apply changes to the DataFrame in place.

relate(other: DataFrame, cache: bool = True) EventsRelation[source]

Create an events data relationship between two linearly referenced datasets.

Parameters:
  • other (DataFrame) – The other DataFrame to relate with. Must have an equivalent linear referencing system.

  • cache (bool, default True) – Whether to cache computed relationship operations, such as intersections and overlays, for faster subsequent operations. For one-time operations or to save on memory use for large datasets, set cache=False.

overlay(other: DataFrame, normalize: bool = False, norm_by: str = 'right', chunksize: int = 1000, grouped: bool = True) csr_array[source]

Overlay two sets of linearly referenced datasets, computing the length or proportion of overlap between each pair of events.

Parameters:
  • other (DataFrame) – The other DataFrame to overlay with. Must have an equivalent linear referencing system.

  • normalize (bool, default False) – Whether overlapping lengths should be normalized to give a proportional result with a float value between 0 and 1.

  • norm_by (str, default 'right') – How overlapping lengths should be normalized. Only applied if normalize is True. - ‘right’ : Normalize by the length of the right events. - ‘left’ : Normalize by the length of the left events.

  • chunksize (int or None, default 1000) – The maximum number of events to process in a single chunk. Input chunksize will affect the memory usage and performance of the function. This does not affect actual results, only computation.

  • grouped (bool, default True) – Whether to process the overlay operation for each group separately. This will affect the memory usage and performance of the function. This does not affect actual results, only computation.

intersect(other: DataFrame, enforce_edges: bool = True, chunksize: int = 1000, grouped: bool = True) csr_array[source]

Identify intersections between two sets of linearly referenced datasets.

Parameters:
  • other (DataFrame) – The other DataFrame to intersect with. Must have an equivalent linear referencing system.

  • enforce_edges (bool, default True) – Whether to consider cases of coincident begin and end points, according to each collection’s closed state. For instances where these cases are not relevant, set enforce_edges=False for improved performance. Ignored for point to point intersections.

  • chunksize (int or None, default 1000) – The maximum number of events to process in a single chunk. Input chunksize will affect the memory usage and performance of the function. This does not affect actual results, only computation.

  • grouped (bool, default True) – Whether to process the overlay operation for each group separately. This will affect the memory usage and performance of the function. This does not affect actual results, only computation.

cluster(max_gap: float, name: str = 'cluster', link_col: str | list[str] | None = None, enforce_edges: bool | None = None, inplace: bool = False) DataFrame | None[source]

Cluster events based on linear referencing proximity within each group. Events whose locations are within the specified max gap of each other (directly or transitively) are assigned to the same cluster.

This method buffers each event location by the max gap to create small linear ranges, then identifies overlapping ranges within each group using a self-intersection, and finally extracts connected components from the resulting adjacency graph to form clusters.

For point events, two points are proximal if their locations are within the max gap distance. For linear events, two events are proximal if their ranges (after extension by the max gap) overlap.

If link_col is provided, events sharing the same link value(s) are additionally connected across groups, allowing clusters to span multiple routes or keys.

Parameters:
  • max_gap (float) – The maximum linear distance between event locations for them to be considered proximal. Events within this distance (directly or transitively through intermediate events) will be assigned to the same cluster.

  • name (str, default 'cluster') – The name of the cluster column to add to the DataFrame.

  • link_col (str, list of str, or None, default None) – Column name(s) identifying shared entities across groups. Events with the same link value(s) are connected in the cluster graph, allowing clusters to bridge across different key groups (e.g., an intersection ID that is shared across multiple routes). Rows with NaN in link columns are not linked.

  • enforce_edges (bool or None, default None) – Whether to treat shared edges (touching boundaries) as intersections. If None, defaults to False for linear events and is disregarded for point events.

  • inplace (bool, default False) – Whether to apply changes to the DataFrame in place.

Returns:

df – A copy of the DataFrame with a new cluster column, or None if inplace=True.

Return type:

DataFrame or None

Raises:

LRSConfigurationError – If the LRS has no location or linear data defined, or if event locations or bounds contain undefined (NaN) values.

generate_intersections(*args, **kwargs)
project(*args, **kwargs)
linref.ext.base.check_compatibility(dfs: list[DataFrame]) list[DataFrame][source]

Validate that all dataframes have compatible LRS objects assigned, raising various errors for incompatible LRS configurations.

Parameters:

dfs (list of DataFrame) – A list of DataFrames to validate.

linref.ext.base.integrate(dfs: list[DataFrame], fill_gaps: bool = False, split_at_locs: bool = False, expand: bool = False, inverse_col: str | list[str] | None = None, **kwargs) DataFrame[source]

Combine multiple linearly referenced dataframes into a single dataframe, creating new linear events based on least common intervals among all input events.

Parameters:
  • dfs (list of DataFrame) – A list of DataFrames with equivalent linear referencing systems to integrate.

  • fill_gaps (bool, default False) – Whether to fill gaps in merged events between the maximum beginning and minimum ending points of all input events within a group. These gaps will be represented as events with no associated input events.

  • split_at_locs (bool, default False) – Whether to split events at location points within the input events. This allows for breaking events at point events as well as linear events.

  • expand (bool, default False) – Whether to expand intervals that match multiple events in any input layer. When True, each interval is duplicated for every combination of matching indices across all layers, ensuring that overlapping source events each receive their own copy of intersecting intervals. When False, each interval is assigned to only the first matching event per layer.

  • inverse_col (str or list of str, optional) – The label or list of labels for the inverse index columns that map integrated events to the original events from each input dataframe. If a single string is provided, all inverse index columns will use the same label with an appended suffix of ‘_0’, ‘_1’, etc. If None, default labels of ‘integrated_index_0’, ‘integrated_index_1’, etc. will be used.

linref.ext.base.parse_geoms_m_wkt(geoms: Series) Series[source]

Parse the WKT representations of M-enabled geometries into a series of LineStringM object.

Parameters:

geoms (pd.Series) – A pandas Series containing WKT representations of M-enabled geometries.

linref.ext.base.parse_geoms_m_shapely(geoms: Series, reverse: bool = False) Series[source]

Parse the Shapely geometry representations of M-enabled geometries into a series of LineStringM object.

NOTE: This method requires Shapely version 2.1 or higher. This process will become deprecated in future versions in favor of direct support for M-enabled geometries in Shapely.

Parameters:
  • geoms (pd.Series) – A pandas Series containing Shapely geometry representations of M-enabled geometries.

  • reverse (bool, default False) – Whether to attempt reversing the geometries in case of decreasing M values. If False, an error will be raised if decreasing M values are detected.

linref.ext.spatial

linref.ext.spatial.parallel_project_hausdorff(target: GeoDataFrame, projected: GeoDataFrame, buffer: float = 0, max_distance: float | None = None, match: int = 1, densify: float | None = None, replace: bool = False) GeoDataFrame[source]

Experimental class for performing projections of linear geometries onto a primary linearly referenced layer using a series of tests based on the Hausdorff distance metric.

The methodology involves the following steps:

1. Identify candidate target geometries by joining the bounds of each projected geometry to the target data using a specified buffer distance. Only target geometries within the buffer distance of both ends of the projected geometry are retained as candidates.

2. For each candidate target geometry, compute the Hausdorff distance between the projected geometry and the target geometry. This distance quantifies the maximum distance of a point on one geometry to the nearest point on the other geometry.

3. Select the target geometry with the minimum Hausdorff distance as the best match for the projected geometry, or specify multiple matches if desired.

4. Project the endpoints of the projected geometry onto the matched target geometry to obtain linear referencing information, producing a new dataframe with the projected geometries referenced to the target’s linear referencing system.

Parameters:
  • target (gpd.GeoDataFrame) – The target GeoDataFrame with m-enabled geometries to project onto.

  • projected (gpd.GeoDataFrame) – The GeoDataFrame containing geometries to be projected. These geometries must be singlepart.

  • buffer (float, default 0) – The buffer distance (in the units of the CRS) to use when identifying candidate target geometries.

  • max_distance (float, optional) – The maximum allowable Hausdorff distance (in the units of the CRS) for a candidate target geometry to be considered a valid match. Geometries with a Hausdorff distance exceeding this value will not be matched. If not specified, will default to be equal to the buffer value.

  • match (int, default 1) – The number of closest matching target geometries to return for each projected geometry based on the Hausdorff distance metric. If set to 1, only the closest match is returned. If set to a value greater than 1, the specified number of closest matches are returned. If set to 0, all candidate matches within the max_distance are returned.

  • densify (float, optional) – A value between 0 and 1 indicating the fraction of each geometry’s length to use for densification when computing the Hausdorff distance. Densification adds additional vertices along the geometry to improve the accuracy of the distance calculation. If not specified, no densification is applied.

  • replace (bool, default False) – If True, will replace any existing linear referencing columns in the projected GeoDataFrame with the newly computed values. If False, will raise an error if the projected GeoDataFrame already contains linear referencing columns from the target’s system.

Returns:

A new GeoDataFrame containing the projected geometries with linear referencing information based on the target’s system.

Return type:

gpd.GeoDataFrame

class linref.ext.spatial.ParallelProjector(target: GeoDataFrame, projected: GeoDataFrame, samples=3, buffer=100)[source]

Bases: object

Experimental class for performing projections of linear geometries onto linear events collections.

The methodology used by this class involves the following steps:

1. Create sample points along the projected geometries using a fixed number of samples per geometry.

2. Spatially join these sample points to the target EventsCollection’s geometry using the provided buffer distance to identify candidate matches.

3. Process all possible matches using the .match() method to produce linear referencing information for the projected geometries based on that of the target EventsCollection.

property target
property target_buffered
property projected
property samples
property buffer
property sample_locs
property sample_points
property projectors
match(match='all', choose=1, sort_locs=True)[source]

Perform the actual matching of nearby geometries to one another based on input analysis parameters, producing a dataframe which has been applied to the target EventsCollection’s linear referencing system.

linref.ext.spatial.generate_intersection_pairs(gdf: GeoDataFrame, exclude_groups: str | list[str] | None = None, touches: bool = True, crosses: bool = True) tuple[ndarray, ndarray, ndarray][source]

Find pairwise intersection geometries between linestring geometries within a GeoDataFrame. Uses spatial predicates to control which types of intersections are returned.

Parameters:
  • gdf (GeoDataFrame) – The GeoDataFrame containing linestring geometries to find intersections within.

  • exclude_groups (str or list of str, optional) – Column name(s) used for group exclusion. Pairs where both geometries share the same value in these columns are excluded from results. Useful for excluding intersections between segments of the same route.

  • touches (bool, default True) – If True, include pairs that share boundary points (endpoints) only.

  • crosses (bool, default True) – If True, include pairs whose interiors intersect (interior crossings).

Returns:

A tuple of three arrays:

  • intersections : Array of intersection geometries (shapely objects).

  • index_left : Array of index labels of the first geometry in each pair.

  • index_right : Array of index labels of the second geometry in each pair.

Return type:

tuple of (ndarray, ndarray, ndarray)

Raises:

ValueError – If both touches and crosses are False.

linref.ext.spatial.generate_intersection_nodes(gdf: GeoDataFrame, exclude_groups: str | list[str] | None = None, touches: bool = True, crosses: bool = True) tuple[ndarray, list[list]][source]

Find unique intersection nodes between geometries in a GeoDataFrame, returning one entry per unique intersection location with the list of all participating source geometry indices.

Calls generate_intersection_pairs() to obtain pairwise results, then explodes multipart geometries and groups by unique location.

Parameters:
  • gdf (GeoDataFrame) – The GeoDataFrame containing geometries to find intersections within.

  • exclude_groups (str or list of str, optional) – Column name(s) used for group exclusion. Pairs where both geometries share the same value in these columns are excluded from results. Useful for excluding intersections between segments of the same route.

  • touches (bool, default True) – If True, include pairs that share boundary points (endpoints) only.

  • crosses (bool, default True) – If True, include pairs whose interiors intersect (interior crossings).

Returns:

A tuple of two elements:

  • geometries : Array of unique intersection geometries.

  • indices : List of lists, where each inner list contains the sorted source geometry index labels participating at that location.

Return type:

tuple of (ndarray, list of list)

linref.ext.validation