A unified python package to parse geospatial data formats and compute typed bounding boxes.
Project description
geombox
A unified, typed Python library to parse geospatial geometries from various formats (WKT, GeoJSON, Shapefiles) and compute their bounding boxes (BBox) and geometries in a target Coordinate Reference System (reprojecting to EPSG:4326 by default).
Installation
You can install geombox using pip:
# Build the wheel
pip wheel --no-deps -w dist .
# Install the built wheel
pip install dist/geombox-*.whl
Features
- Unified API: Parse multiple geometry representations (
WKT,GeoJSON,Shapefiles) with a single function call. - Typed Representation: Bounding boxes are returned as a typed, immutable
dataclass(with helpers to export to tuple or GeoJSON dictionary formats). - Automatic Reprojection: Safely handles coordinates reprojection using
pyprojandshapely. High precision bounding box calculation reprojects the entire geometry prior to computing the bounds to prevent edge curvature errors. - Robust Exception Handling: Custom, descriptive error types for parsing errors, reprojection failures, or invalid geometries.
Usage
import geombox
# Calculate a bounding box from a WKT string (automatically reprojected to EPSG:4326)
wkt_input = "POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))"
bbox = geombox.get_bbox(wkt_input)
print(bbox)
# BoundingBox(min_x=10.0, min_y=10.0, max_x=40.0, max_y=40.0, crs='EPSG:4326')
# Convert the bounding box representation
print(bbox.as_tuple()) # (10.0, 10.0, 40.0, 40.0)
print(bbox.as_geojson()) # GeoJSON dict polygon
# Parse and reproject to UTM zone 14N
utm_bbox = geombox.get_bbox(wkt_input, target_crs="EPSG:32614")
print(utm_bbox)
# Get the full reprojected shapely geometry
geom = geombox.get_geometry(wkt_input, target_crs="EPSG:4326")
print(geom.wkt)
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 geombox-0.1.0.tar.gz.
File metadata
- Download URL: geombox-0.1.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1dc799d5fcc7ede3ab812969b2957e8e0055df7a4f6abf02ca89d784fa85383
|
|
| MD5 |
6084721079962732151e346b4a2922b8
|
|
| BLAKE2b-256 |
ab0a5d21c2a4de775f1777b2d7d74df6d5c9aad457a5f90ddfbbbf1bdaa86082
|
File details
Details for the file geombox-0.1.0-py3-none-any.whl.
File metadata
- Download URL: geombox-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f5ac7d63e712c91aad5115eab10a235af639ea41a8fb5adb29b91068b0ec042
|
|
| MD5 |
810881b65b4f7b27f8d48c91c22d5387
|
|
| BLAKE2b-256 |
4690d84a7c4caac8dd97002a4410b49295fab7803839c7d85c72795bca24c0da
|