blocksnet.preprocessing.blocks_generator

Module to generate blocks (land parcels) based on boundaries, roads, railways, and water objects.

Classes

BlocksGenerator(boundaries[, roads, ...])

Generates blocks (land parcels) based on boundaries, roads, railways, and water objects.

BlocksSchema(*args, **kwargs)

BoundariesSchema(*args, **kwargs)

RailwaysSchema(*args, **kwargs)

RoadsSchema(*args, **kwargs)

WaterSchema(*args, **kwargs)

class blocksnet.preprocessing.blocks_generator.BoundariesSchema(*args, **kwargs)[source]

Bases: BaseSchema

class Config

Bases: Config

name = 'BoundariesSchema'
class blocksnet.preprocessing.blocks_generator.RoadsSchema(*args, **kwargs)[source]

Bases: BaseSchema

class Config

Bases: Config

name = 'RoadsSchema'
class blocksnet.preprocessing.blocks_generator.RailwaysSchema(*args, **kwargs)[source]

Bases: BaseSchema

class Config

Bases: Config

name = 'RailwaysSchema'
class blocksnet.preprocessing.blocks_generator.WaterSchema(*args, **kwargs)[source]

Bases: BaseSchema

class Config

Bases: Config

name = 'WaterSchema'
class blocksnet.preprocessing.blocks_generator.BlocksSchema(*args, **kwargs)[source]

Bases: BaseSchema

class Config

Bases: Config

name = 'BlocksSchema'
class blocksnet.preprocessing.blocks_generator.BlocksGenerator(boundaries: GeoDataFrame, roads: GeoDataFrame | None = None, railways: GeoDataFrame | None = None, water: GeoDataFrame | None = None)[source]

Bases: object

Generates blocks (land parcels) based on boundaries, roads, railways, and water objects.

Parameters:
  • boundaries (gpd.GeoDataFrame) – Boundaries of a city or a territory. Must contain geometry column of Polygon or MultiPolygon geometries.

  • roads (gpd.GeoDataFrame | None, optional) – Roads geometries. Can be obtained via OSMnx and must contain geometry column of LineString geometries. By default None.

  • railways (gpd.GeoDataFrame | None, optional) – Railways geometries. Can be obtained via OSM tags railway==rail and must contain geometry column of LineString geometries. By default None.

  • water (gpd.GeoDataFrame | None, optional) – Water objects geometries. Can be obtained via OSM tags like riverbank==*, pond==*, etc. Must contain geometry column of LineString, Polygon or MultiPolygon. By default None.

run(min_block_width=None)[source]

Generates blocks based on the provided boundaries, roads, railways, and water objects.

property local_crs: CRS

Local CRS, defined by boundaries geometry.

Returns:

pyproj.CRS object

Return type:

CRS

run(min_block_width: float | None = None) GeoDataFrame[source]

Generates blocks based on the provided boundaries, roads, railways, and water bodies.

Parameters:

min_block_width (float, optional) – Minimum width for the blocks. If specified, small blocks and bottlenecks will be filtered out. By default None.

Returns:

GeoDataFrame containing the generated blocks with geometry column.

Return type:

gpd.GeoDataFrame

static _get_enclosures(barriers: GeoDataFrame, limit: GeoDataFrame)[source]

Identifies enclosures formed by the barriers and within the limit.

Parameters:
  • barriers (gpd.GeoDataFrame) – GeoDataFrame containing barrier geometries.

  • limit (gpd.GeoDataFrame) – GeoDataFrame containing the limit within which enclosures are to be found.

Returns:

GeoDataFrame containing the identified enclosures.

Return type:

gpd.GeoDataFrame

static _reindex_blocks(blocks: GeoDataFrame)[source]

Reindexes the blocks, ensuring each block has a unique block_id.

Parameters:

blocks (gpd.GeoDataFrame) – GeoDataFrame containing the blocks to be reindexed.

Returns:

GeoDataFrame with reindexed blocks.

Return type:

gpd.GeoDataFrame