revrt.routing.utilities.PointToFeatureMapper#
- class PointToFeatureMapper(crs, features_fp, regions=None, region_identifier_column='rid', connection_identifier_column='end_feat_id')[source]#
Bases:
objectMap points to features within specified regions and/or radii
- Parameters:
crs (
strorpyproj.crs.CRS) – Coordinate reference system to use for all spatial data.features_fp (path-like) – File path to transmission features to map points to.
regions (
geopandas.GeoDataFrameor path-like, optional) – Regions to use for clipping features around points. Features will not extend beyond these regions, and point will only map to features within their own region. This input can be paired with the radius parameter (e.g. to forbid any connections to cross state boundaries, even if that connection would be shorter than some desired length). At least one of regions or radius must be provided; otherwise, an error is raised. By default,None.region_identifier_column (
str, default"rid") – Column in regions data to use as the identifier for that region. If not given, a simple index will be put under the rid column. By default,"rid".connection_identifier_column (
str, optional) – Column in output data (both features and points) that will be used to link the points to the features that should be routed to. By default,"end_feat_id".
Methods
map_points(points, feature_out_fp[, radius, ...])Map points to features within the point region
- map_points(points, feature_out_fp, radius=None, expand_radius=True, clip_points_to_regions=False, batch_size=500)[source]#
Map points to features within the point region
- Parameters:
points (
geopandas.GeoDataFrame) – Points to map to features.feature_out_fp (path-like) – File path to save clipped features to. This should end in ‘.gpkg’ to ensure proper format. If not, the extension will be added automatically. This file will contain all features clipped to each point (with a feature ID column added to link back to the points).
radius (
floatorstr, optional) – Radius (in CRS units) around each point to clip features to. If str, the column in points to use for radius values. IfNone, only regions are used for clipping. By default,None.expand_radius (
bool, optional) – IfTrue, the radius is expanded until at least one feature is found. By default,True.clip_points_to_regions (
bool, defaultFalse) – IfTrue, points are clipped to the given regions before mapping to features. If the regions input is not set, this parameter has no effect. IfFalse, all points are used as-is, which means points outside of the regions domain are mapped to the closest region. By default,False.batch_size (
int, default500) – Number of points to process in each batch when writing clipped features to file. By default,500.
- Returns:
geopandas.GeoDataFrame– Input points with added column giving mapped feature IDs.