A Python library for regularizing building footprints in geospatial data. This library helps clean up and standardize building polygon geometries by aligning edges to principal directions.
Project description
Building Footprint Regularization
A Python library for regularizing building footprints in geospatial data. This library helps clean up and standardize building polygon geometries by aligning edges to principal directions.
Example Results
Before and after regularization:
Overview
Building footprints extracted from remote sensing imagery often contain noise, irregular edges, and geometric inconsistencies. This library provides tools to regularize these footprints by:
- Aligning edges to principal directions
- Converting near-rectangular buildings to perfect rectangles
- Simplifying complex polygons while maintaining their essential shape
Inspired by RS-building-regularization, this library takes a geometric approach to building regularization with improvements for usability and integration with the GeoPandas ecosystem.
Installation
pip install buildingregulariser
Quick Start
import geopandas as gpd
from buildingregulariser import regularize_geodataframe
# Load your building footprints
buildings = gpd.read_file("buildings.gpkg")
# Regularize the building footprints
regularized_buildings = regularize_geodataframe(
buildings,
)
# Save the results
regularized_buildings.to_file("regularized_buildings.gpkg")
Features
- GeoDataFrame Integration: Works seamlessly with GeoPandas GeoDataFrames
- CRS Handling: Intelligently handles coordinate reference systems
- Polygon Regularization: Aligns edges to principal directions
- Edge Simplification: Reduces the number of vertices while preserving shape
- Geometry Cleanup: Fixes invalid geometries and removes artifacts
Usage Examples
Basic Regularization
from buildingregulariser import regularize_geodataframe
import geopandas as gpd
buildings = gpd.read_file("buildings.gpkg")
regularized = regularize_geodataframe(buildings)
Working with Different Coordinate Systems
regularized = regularize_geodataframe(
buildings,
target_crs="EPSG:3857" # Web Mercator projection
)
Fine-tuning Regularization Parameters
regularized = regularize_geodataframe(
buildings,
parallel_threshold=2.0, # Higher values allow more edge alignment
simplify=True,
simplify_tolerance=0.5 # Controls simplification level
)
Parameters:
- geodataframe: Input GeoDataFrame with polygon geometries
- parallel_threshold: Distance threshold for handling parallel lines (default: 1.0)
- target_crs: Target CRS for reprojection. If None, uses the input CRS
- simplify: If True, applies simplification to the geometry (default: True)
- simplify_tolerance: Tolerance for simplification (default: 0.5)
Returns:
- A new GeoDataFrame with regularized polygon geometries
How It Works
- Edge Analysis: Analyzes each polygon to identify principal directions
- Edge Orientation: Aligns edges to be either parallel or perpendicular to the main direction
- Edge Connection: Ensures proper connectivity between oriented edges
License
This project is licensed under the MIT License
Acknowledgments
This library was inspired by the RS-building-regularization project, with improvements for integration with the GeoPandas ecosystem and enhanced regularization algorithms.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file buildingregulariser-0.1.3.tar.gz.
File metadata
- Download URL: buildingregulariser-0.1.3.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
208c94f225e3a45056cdbc46bb4f86a6d4f42647feaec1b8d8b3b940f25ca75d
|
|
| MD5 |
b6106a4ecf40516f49e69bf88b8cce77
|
|
| BLAKE2b-256 |
fdebfc8b1696348cfd9bd6c4adbdffabaae4572f03a6b3828d865b2e49578305
|
File details
Details for the file buildingregulariser-0.1.3-py3-none-any.whl.
File metadata
- Download URL: buildingregulariser-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7574e497f85f5f346a1a85f72be4a04392d7f4d06da83e9e96540c8174b9d585
|
|
| MD5 |
f517e6867fc3672cf105d366220e9ba1
|
|
| BLAKE2b-256 |
1d96cb1b35096390f7d2ba95ac44f4b3e4419c08862213bc9bd3b3660f524fbc
|