Metadata-Version: 2.1
Name: uraster
Version: 0.1.0
Summary: A Python package for unstructured raster processing and remapping
Author-email: Chang Liao <changliao.climate@gmail.com>
Maintainer-email: Chang Liao <changliao.climate@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2022, Battelle Memorial Institute
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Project-URL: Homepage, https://github.com/changliao1025/uraster
Project-URL: Documentation, https://github.com/changliao1025/uraster
Project-URL: Repository, https://github.com/changliao1025/uraster
Project-URL: Bug Tracker, https://github.com/changliao1025/uraster/issues
Keywords: raster,GIS,geospatial,GDAL,unstructured
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: GIS
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.19.0
Requires-Dist: gdal>=3.0.0
Requires-Dist: pyearth>=0.1.0
Requires-Dist: psutil>=5.0.0
Requires-Dist: geovista>=0.3.0
Requires-Dist: vtk==9.3.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"

# uraster: Structured Raster to Unstructured Mesh

## Overview

**uraster** is a Python package to convert or transfer structured raster dataset into unstructured mesh formats, designed to bridge the gap between structured raster data and unstructured mesh-based numerical models. It leverages GDAL/OGR for robust data handling.


[quickstart documentation](https://uraster.readthedocs.io/en/latest/quickstart.html)

## ✨ Core Features

- **GDAL-Native Vector Handling**: Uses the standard GDAL/OGR engine for defining unstructured mesh cells, and performing projection-aware geospatial operations.

- **Standard Vector I/O**: Instead of directly operating on various mesh standards, it utilizes standard geographic information system vector formats (e.g., GeoJSON) for mesh operations, ensuring broad compatibility. It supports transformation APIs between existing meshes and standard vector formats.

- **Projection-Aware Operations**: Handles (raster dateaset) map projection differences to ensure accurate aggregation of raster values within each polygon.

- **Interactive GeoVista API**: Offers simple functions to visualize the input and the output vector layers on a 3D sphere.

## 💻 Installation

uraster requires GDAL for vector handling and GeoVista (which relies on PyVista/VTK) for 3D visualization.

> ⚠️ **GDAL Note**: Installing GDAL's Python bindings can be complex via pip due to platform dependencies. We strongly recommend using Conda for a stable installation of GDAL and all dependencies.

### Install via Conda (Recommended)
```bash
# Create a new conda environment (recommended)
conda create -n uraster-env python=3.9
conda activate uraster-env

# Install uraster and all dependencies via conda
conda install -c conda-forge uraster
```

### Development Installation
```bash
git clone https://github.com/changliao1025/uraster.git
cd uraster
conda install -c conda-forge gdal geovista vtk=9.3.0 pyearth
conda develop .
```

## 🚀 Quick Start

### Example 1: Basic Zonal Statistics
This example demonstrates how to perform zonal statistics on unstructured mesh data:

```python
import uraster
from uraster.classes.uraster import uraster

# Configuration
config = {
    'sFilename_source_mesh': 'path/to/your/mesh.geojson',
    'aFilename_source_raster': ['path/to/your/raster.tif'],
    'sFilename_target_mesh': 'path/to/output/mesh_with_stats.geojson'
}

# Create uraster instance
processor = uraster(config)

# Setup and validate inputs
processor.setup(iFlag_verbose=True)

# Print input information
processor.report_inputs()

# Run zonal statistics
processor.run_remap(iFlag_verbose=True)

# Visualize results
processor.visualize_target_mesh(
    sVariable_in='mean',
    sFilename_out='output_visualization.png',
    sColormap='viridis'
)
```

### Example 2: Global Analysis with Animation
```python
import uraster
from uraster.classes.uraster import uraster

# Configuration for global analysis
config = {
    'sFilename_source_mesh': 'global_mesh.geojson',
    'aFilename_source_raster': ['global_dem.tif'],
    'sFilename_target_mesh': 'global_mesh_with_elevation.geojson'
}

processor = uraster(config)
processor.setup(iFlag_verbose=True)
processor.run_remap()

# Create rotating animation
processor.visualize_target_mesh(
    sVariable_in='mean',
    sFilename_out='global_elevation.mp4',
    sColormap='terrain',
    iFlag_create_animation=True,
    iAnimation_frames=360,
    sAnimation_format='mp4'
)
```

## 📊 Supported Formats

- **Mesh formats**: GeoJSON, Shapefile, any OGR-supported vector format
- **Raster formats**: GeoTIFF, NetCDF, HDF5, any GDAL-supported raster format
- **Output formats**: GeoJSON (with computed statistics), PNG/JPG (visualizations), MP4/GIF (animations)

## 🤝 Contributing & License

We welcome contributions! Please open an issue or submit a pull request on the GitHub repository.

**uraster** is distributed under the BSD 3-Clause License.

