RoadwayRegularizer

RoadwayRegularizer#

class rapidtools.processing.RoadwayRegularizer(min_width_ft: float = ..., min_network_length_ft: float = ..., output: Literal['both'] = ...)[source]#
class rapidtools.processing.RoadwayRegularizer(min_width_ft: float = ..., min_network_length_ft: float = ..., *, output: Literal['polygons', 'centerlines'])
class rapidtools.processing.RoadwayRegularizer(min_width_ft: float = ..., min_network_length_ft: float = ..., output: str = ...)

Bases: Generic[_OutT]

Pipeline component to regularize jagged raster-to-vector road polygons.

This regularizer processes raw input geometries, extracts a Voronoi-based centerline skeleton, heals the graph, merges collinear segments, and statistically samples widths. It outputs in-memory PhysicalAssetCollection objects for both the centerlines and the reconstructed polygons.

Parameters:
  • min_width_ft (float, optional) – The minimum enforced width for any regularized road segment in feet. Defaults to 22.0.

  • min_network_length_ft (float, optional) – The minimum cumulative length a connected skeleton component must possess to be considered a valid road network. Any disconnected stub networks shorter than this value will be filtered out. Defaults to 100.0.

Example

>>> from rapidtools.core import PhysicalAssetCollection
>>> from rapidtools.processing import RoadwayRegularizer
>>>
>>> raw = PhysicalAssetCollection.from_geojson('roads_raw.geojson')
>>> regularizer = RoadwayRegularizer(
...     min_width_ft=22.0, min_network_length_ft=150.0
... )
>>> centerlines, polygons = regularizer(raw)
>>> centerlines[0].attributes
{'asset_type': 'road_centerline', 'width_ft': 24.5, 'azimuth_deg': 91.2}

Methods

process

Execute the regularization logic and return asset collections.

process(input_assets: PhysicalAssetCollection) → tuple[PhysicalAssetCollection, PhysicalAssetCollection][source]#

Execute the regularization logic and return asset collections.

The steps are: project to a local feet-based CRS, drop polygons smaller than MIN_POLYGON_AREA_SQFT, fuse near-touching polygons, skeletonize with a Voronoi diagram, heal/prune the skeleton graph, remove short stub networks, chain the edges that continue each other and fit a centerline to each chain (straight where the skeleton is, curved where it curves), sample widths and azimuths, and finally rebuild WGS84 centerline and polygon assets, with the corners of intersections rounded where the input shows them rounded.

Parameters:

input_assets (PhysicalAssetCollection) – The raw input road polygons (WGS84).

Returns:

tuple[PhysicalAssetCollection, PhysicalAssetCollection] – A tuple containing:

  • centerlines_collection: Assets representing the road centerlines (LineString geometries) with the attributes 'asset_type': 'road_centerline', 'width_ft' and 'azimuth_deg'.

  • polygons_collection: Assets representing the regularized polygons with 'asset_type': 'road_polygon' and the same width/azimuth attributes.

Both collections are empty when the input is empty or when no polygon exceeds the minimum area.

Example

>>> centerlines, polygons = RoadwayRegularizer().process(raw_roads)
>>> polygons[0].attributes['asset_type']
'road_polygon'