reVeal.grid.get_neighbors#
- get_neighbors(grid_df, order)[source]#
Create new geometry for each cell in the input grid, consisting of a union with neighboring cells of the specified contiguity order.
- Parameters:
grid_df (geopandas.GeoDataFrame) – Input grid geodataframe. This should be a polygon geodataframe where all geometries form a coverage (i.e., a non-overlapping mesh) and neighboring geometries share only points or segments of the exterior boundaries. This function also assumes that the index of zones_df is unique for each feature. If either of these are not the case, unexpected results may occur.
order (int) – Neighbor order to apply. For example, order=1 will group all first-order queen’s contiguity neighbors into a new grid cell, labeled based on the center grid cell.
- Returns:
gpd.GeoDataFrame – A GeoDataFrame with the grid transformed into larger cells based on neighbors.