urbanflow.utils.poi_utils¶
Functions
|
Convert a CRS-aligned point to (row, col). |
|
Map POI coordinates to grid indices AND snap them to the nearest 'door cell' (street cell adjacent to a building). |
|
- urbanflow.utils.poi_utils.point_to_cell(x, y, transform)¶
Convert a CRS-aligned point to (row, col). Raises ValueError if the point is outside the grid.
- Parameters:
x (float)
y (float)
transform (Affine)
- Return type:
Tuple[int, int]
- urbanflow.utils.poi_utils.pois_to_grid_coords(poi_gdf, transform, grid, *, do_adjusted=True, keep_outside=False, street_code=1, building_code=2)¶
Map POI coordinates to grid indices AND snap them to the nearest ‘door cell’ (street cell adjacent to a building).
- Parameters:
poi_gdf (GeoDataFrame – must be in the same CRS as transform)
transform (Affine – from gdfs_to_grid / venice_grid)
grid (ndarray[uint8] – the uint8 grid with state codes)
keep_outside (bool – keep/drop POIs that fall outside grid)
street_code (int – codes used in grid)
building_code (int – codes used in grid)
do_adjusted (bool)
- Returns:
row, col integer indices of the original cell row_adj, col_adj integer indices of the snapped door cell
- Return type:
GeoDataFrame – original columns +
- urbanflow.utils.poi_utils.pois_within_radius(poi_gdf, poi_idx, meta_val, radius_m, distance_col='distance_m', prefer_same_parish=False)¶
- Parameters:
poi_gdf (GeoDataFrame) – Full POI table (must have ‘geometry’, ‘PP_Bottega_METACATEGORY’, and optionally ‘parish_std’).
poi_idx (int) – Row position of the central POI in poi_gdf.
meta_val (str) – Desired PP_Bottega_METACATEGORY value.
radius_m (float) – Search radius in metres.
distance_col (str, optional) – Column name that will store computed centre-to-POI distances.
prefer_same_parish (bool, optional) – If True, results from the same parish (parish_std) as the centre POI are listed first (default False).
- Returns:
Matching POIs within radius, sorted by parish preference (if enabled) and then by straight-line distance.
- Return type:
GeoDataFrame