Metadata-Version: 2.4
Name: pyearthbuffer
Version: 0.1.0
Summary: Geographic Coordinate System Buffer Operations in Python
Author-email: Chang Liao <changliao.climate@gmail.com>
License: BSD-3-Clause
Project-URL: Homepage, https://github.com/changliao1025/pyearthbuffer
Project-URL: Documentation, https://pyearthbuffer.readthedocs.io
Project-URL: Repository, https://github.com/changliao1025/pyearthbuffer
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Scientific/Engineering :: GIS
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE.md
License-File: AUTHORS.rst
Requires-Dist: gdal
Requires-Dist: numpy
Requires-Dist: pyearth>=0.2.5
Requires-Dist: scipy
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

# PyEarthBuffer

Geographic Coordinate System (GCS) Buffer Operations in Python.

If you find this package useful, please cite it in your work.
You can also support it by [buying me a coffee](https://www.buymeacoffee.com/changliao) or sponsoring it on [GitHub](https://github.com/sponsors/changliao1025).

## Dependencies

`pyearthbuffer` directly depends on the following packages:

1. `gdal`
2. `numpy`
3. `pyearth`
4. `scipy`

## Documentation

Please refer to the [documentation](https://pyearthbuffer.readthedocs.io) for details on how to get started using the `pyearthbuffer` package.

## Installation

`pyearthbuffer` depends on several geospatial packages including `gdal`, which are most reliably installed through `conda`:

```bash
conda install -c conda-forge pyearthbuffer
```

Or install from source in editable mode:

```bash
pip install -e .
```

## Features

`pyearthbuffer` provides geodesic buffer operations on the WGS84 ellipsoid:

1. **Object-based vector buffer (`gcsbuffer`)**:
   - Geodesic buffers for Points, LineStrings, Polygons, and Multi-geometries.
   - Accepts WKT strings, GeoJSON mappings, OGR geometries, or coordinate sequences.
   - Formats output as WKT, GeoJSON, or OGR geometry objects.
   - Explicit helpers: `gcsbuffer_point`, `gcsbuffer_line`, `gcsbuffer_polygon`.

2. **File-based vector batch buffer (`gcsbuffer_file`)**:
   - Batch-processes GIS vector files (Shapefile, GeoJSON, GeoPackage, etc.).
   - Preserves feature attribute tables and schema.
   - Supports dissolve/union (`dissolve=True`) and polygon area filtering (`min_area`).
   - Explicit helpers: `gcsbuffer_point_file`, `gcsbuffer_line_file`, `gcsbuffer_polygon_file`.

## Quick Start

### 1. In-Memory Geometry Buffering

```python
import pyearthbuffer as peb

# Buffer a point (lon, lat) by 1,000 meters
point_wkt = peb.gcsbuffer((-74.006, 40.7128), distance=1000.0)

# Buffer a line corridor to GeoJSON
line_wkt = "LINESTRING (-74.006 40.7128, -73.990 40.7200)"
corridor = peb.gcsbuffer(line_wkt, distance=50.0, output_format="geojson")

# Buffer a polygon
poly_wkt = "POLYGON ((-74.0 40.7, -74.0 40.8, -73.9 40.8, -73.9 40.7, -74.0 40.7))"
poly_buffered = peb.gcsbuffer(poly_wkt, distance=500.0)
```

### 2. Batch File Buffering

```python
import pyearthbuffer as peb

# Buffer an entire vector dataset file
peb.gcsbuffer_file(
    input_file="input_roads.geojson",
    output_file="output_corridors.shp",
    distance=100.0,
    dissolve=True,  # Merge overlapping buffer zones
    preserve_attributes=True,
)
```

## Acknowledgment

This research was supported as part of the Next Generation Ecosystem Experiments-Tropics, funded by the U.S. Department of Energy, Office of Science, Office of Biological and Environmental Research at Pacific Northwest National Laboratory. The study was also partly supported by U.S. Department of Energy Office of Science Biological and Environmental Research through the Earth and Environmental System Modeling program as part of the Energy Exascale Earth System Model (E3SM) project.

## License

BSD 3-Clause License. See [LICENSE.md](LICENSE.md) for details.
