blocksnet.preprocessing.land_use_processor

Module that processes data to classify blocks based on their intersection with predefined standardized zones.

Classes

BlocksSchema(*args, **kwargs)

Schema for validating blocks GeoDataFrame.

LandUseProcessor(blocks, zones[, ...])

Processes data to classify blocks based on their intersection with predefined standardized zones.

ProcessedBlocksSchema(*args, **kwargs)

Extended BlocksSchema to include zone and land use information.

ZonesSchema(*args, **kwargs)

Schema for validating zones GeoDataFrame.

class blocksnet.preprocessing.land_use_processor.BlocksSchema(*args, **kwargs)[source]

Bases: BaseSchema

Schema for validating blocks GeoDataFrame.

Variables:

_geom_types (list) – List of valid geometry types for the schema, set to shapely.Polygon.

class Config

Bases: Config

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

Bases: BaseSchema

Schema for validating zones GeoDataFrame.

Variables:
  • _geom_types (list) – List of valid geometry types for the schema, set to shapely.Polygon and shapely.MultiPolygon.

  • zone (Series[str]) – Pandera Series to enforce zone column type as string.

zone: Series[str] = 'zone'
class Config

Bases: Config

name = 'ZonesSchema'
class blocksnet.preprocessing.land_use_processor.ProcessedBlocksSchema(*args, **kwargs)[source]

Bases: BlocksSchema

Extended BlocksSchema to include zone and land use information.

Variables:
  • zone (Series[str]) – Pandera Series to enforce zone column type as string. Nullable, default is None.

  • land_use (Series[str]) – Pandera Series to enforce land use column type as string. Nullable, default is None.

zone: Series[str] = 'zone'
land_use: Series[str] = 'land_use'
class Config

Bases: Config

name = 'ProcessedBlocksSchema'
class blocksnet.preprocessing.land_use_processor.LandUseProcessor(blocks: GeoDataFrame, zones: GeoDataFrame, zone_to_land_use: dict[str, blocksnet.models.land_use.LandUse] = {'Т1Ж1': LandUse.RESIDENTIAL, 'Т1Ж2-1': LandUse.RESIDENTIAL, 'Т1Ж2-2': LandUse.RESIDENTIAL, 'Т2Ж1': LandUse.RESIDENTIAL, 'Т2ЖД2': LandUse.RESIDENTIAL, 'Т3Ж1': LandUse.RESIDENTIAL, 'Т3Ж2': LandUse.RESIDENTIAL, 'Т3ЖД3': LandUse.RESIDENTIAL, 'ТД1-1': LandUse.RESIDENTIAL, 'ТД1-2': LandUse.RESIDENTIAL, 'ТД1-3': LandUse.BUSINESS, 'ТД2': LandUse.BUSINESS, 'ТД3': LandUse.BUSINESS, 'ТИ1-1': LandUse.TRANSPORT, 'ТИ1-2': LandUse.TRANSPORT, 'ТИ2': LandUse.TRANSPORT, 'ТИ3': LandUse.TRANSPORT, 'ТИ4': LandUse.TRANSPORT, 'ТК1': LandUse.SPECIAL, 'ТК2': LandUse.SPECIAL, 'ТК3': LandUse.SPECIAL, 'ТП1': LandUse.INDUSTRIAL, 'ТП2': LandUse.INDUSTRIAL, 'ТП3': LandUse.INDUSTRIAL, 'ТП4': LandUse.INDUSTRIAL, 'ТПД1': LandUse.INDUSTRIAL, 'ТПД2': LandUse.INDUSTRIAL, 'ТР0-1': LandUse.RECREATION, 'ТР0-2': LandUse.RECREATION, 'ТР1': LandUse.RECREATION, 'ТР2': LandUse.RECREATION, 'ТР3-1': LandUse.RECREATION, 'ТР3-2': LandUse.RECREATION, 'ТР4': LandUse.RECREATION, 'ТР5-1': LandUse.RECREATION, 'ТР5-2': LandUse.RECREATION, 'ТС1': LandUse.AGRICULTURE, 'ТС2': LandUse.SPECIAL, 'ТУ': LandUse.TRANSPORT})[source]

Bases: object

Processes data to classify blocks based on their intersection with predefined standardized zones.

Parameters:
  • blocks (gpd.GeoDataFrame) – GeoDataFrame containing block data. Must contain the following columns: - index : int - geometry : Polygon

  • zones (gpd.GeoDataFrame) – GeoDataFrame containing zone data. Must contain the following columns: - index : int - geometry : Polygon or MultiPolygon - zone : str

  • zone_to_land_use (dict[str, LandUse], optional) – Dictionary mapping zone codes to LandUse enums, default is DEFAULT_ZONE_TO_LAND_USE.

Raises:

AssertionError – If the Coordinate Reference Systems (CRS) of blocks and zones do not match. If any zone in zones is not present in zone_to_land_use keys.

run(min_intersection: float = 0.3) gpd.GeoDataFrame[source]

Processes the blocks and zones to classify the blocks based on land use.

Parameters:

min_intersection (float) – Threshold, minimum area (share) covered by geometry from df_with_attribute. If intersection > min_intersection, then attribute is recorded to df, default is 0.3.

Returns:

GeoDataFrame containing the processed blocks with land use classifications.

Return type:

gpd.GeoDataFrame

run(min_intersection: float = 0.3) GeoDataFrame[source]

Processes the blocks and zones to classify the blocks based on land use.

Parameters:

min_intersection (float) – Threshold, minimum area (share) covered by geometry from df_with_attribute. If intersection > min_intersection, then attribute is recorded to df, default is 0.3.

Returns:

GeoDataFrame containing the processed blocks with land use classifications.

Return type:

gpd.GeoDataFrame