Metadata-Version: 2.4
Name: edown
Version: 0.2.1
Summary: Native-grid Google Earth Engine downloader with optional alignment-aware Zarr stacking.
Project-URL: Homepage, https://github.com/MarcYin/edown
Project-URL: Documentation, https://marcyin.github.io/edown/
Project-URL: Issues, https://github.com/MarcYin/edown/issues
Author: Marc Yin
License: MIT License
        
        Copyright (c) 2026 Marc Yin
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: download,earth-engine,gee,geospatial,raster
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
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: Topic :: Scientific/Engineering :: GIS
Requires-Python: <3.15,>=3.9
Requires-Dist: click>=8.1
Requires-Dist: earthengine-api>=0.1.397
Requires-Dist: numpy>=1.24
Requires-Dist: pyproj>=3.5
Requires-Dist: rasterio>=1.3
Requires-Dist: shapely>=2.0
Requires-Dist: tenacity>=8.2
Provides-Extra: dask
Requires-Dist: dask-jobqueue>=0.8.5; extra == 'dask'
Requires-Dist: distributed>=2024.1.0; extra == 'dask'
Requires-Dist: tqdm>=4.66; extra == 'dask'
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: pytest-mock>=3.12; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.24; extra == 'docs'
Provides-Extra: stack
Requires-Dist: dask[array]>=2024.1.0; extra == 'stack'
Requires-Dist: xarray>=2024.1.0; extra == 'stack'
Requires-Dist: zarr>=2.17; extra == 'stack'
Description-Content-Type: text/markdown

# edown

`edown` is a Google Earth Engine downloader that discovers images for a location and time range, downloads each image in its native grid as GeoTIFF, and can optionally build Zarr stacks for grid-compatible groups.

## What It Does

- Searches an ImageCollection by date range and AOI.
- Preserves each image's native CRS and transform instead of forcing a common projection.
- Downloads intersecting chunks in parallel across multiple images.
- Writes a run manifest with discovery, download, and stack metadata.
- Builds Zarr outputs only when images share an alignment signature.

## Installation

```bash
python -m pip install edown
```

`edown` supports Python 3.9 through 3.14.

For local development:

```bash
python -m pip install -e ".[dev,stack,dask]"
```

## Authentication

`edown` prefers Earth Engine service-account credentials when both of these environment variables are set:

- `GEE_SERVICE_ACCOUNT`
- `GEE_SERVICE_ACCOUNT_KEY`

Otherwise it tries, in order:

- persistent Earth Engine user credentials
- Google application default credentials

If both user-auth and ADC refresh tokens are stale, reauthenticate before running downloads.

## CLI

Search only:

```bash
edown search \
  --collection-id COPERNICUS/S2_SR_HARMONIZED \
  --start-date 2024-06-01 \
  --end-date 2024-06-07 \
  --bbox -0.15 51.48 0.02 51.56 \
  --band B4 \
  --band B8 \
  --manifest-path manifests/search.json
```

Download native-grid GeoTIFFs:

```bash
edown download \
  --collection-id COPERNICUS/S2_SR_HARMONIZED \
  --start-date 2024-06-01 \
  --end-date 2024-06-07 \
  --geojson docs/examples/aoi.geojson \
  --band B4 \
  --band B8 \
  --output-root ./data
```

Build Zarr stacks from compatible groups:

```bash
edown stack \
  --manifest-path manifests/run.json \
  --output-root ./data
```

Run the bundled end-to-end Sentinel-2 example:

```bash
python examples/s2_find_download_stack.py --output-root ./data/live-s2
```

## Python API

```python
from pathlib import Path

from edown import AOI, DownloadConfig, download_images

config = DownloadConfig(
    collection_id="COPERNICUS/S2_SR_HARMONIZED",
    start_date="2024-06-01",
    end_date="2024-06-07",
    aoi=AOI.from_bbox((-0.15, 51.48, 0.02, 51.56)),
    bands=("B4", "B8"),
    output_root=Path("data"),
)

summary = download_images(config)
print(summary.manifest_path)
```

## Live Integration Test

The default test suite is mocked and offline. For a real end-to-end Sentinel-2 smoke test, install the stack extras:

```bash
python -m pip install -e ".[dev,stack]"
```

Then run:

```bash
export EDOWN_RUN_LIVE_TESTS=1
python -m pytest -s tests/test_live_s2.py
```

Default live settings:

- collection: `COPERNICUS/S2_SR_HARMONIZED`
- dates: `2024-06-01` through `2024-06-03`
- bbox: `-0.1278,51.5072,-0.1270,51.5078`
- bands: `B4,B8`

You can override them with:

- `EDOWN_LIVE_COLLECTION_ID`
- `EDOWN_LIVE_START_DATE`
- `EDOWN_LIVE_END_DATE`
- `EDOWN_LIVE_BBOX`
- `EDOWN_LIVE_BANDS`

This requires valid Earth Engine authentication, via either:

- `GEE_SERVICE_ACCOUNT` and `GEE_SERVICE_ACCOUNT_KEY` (path to a service-account JSON key file)
- existing local Earth Engine credentials
- valid Google application default credentials

## Notes

- `--chunk-size` is only used as an exact size when `--chunk-size-mode fixed` is set.
- In the default `auto` mode, `edown` estimates chunk sizes per image from the AOI window and request byte limits.

## Development

- `python -m pytest`
- `ruff check .`
- `mypy src`
- `python -m build`

Docs are built with MkDocs Material and published to GitHub Pages from GitHub Actions.
