Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Python
__pycache__/
*.py[cod]
*.pyo
*.pyd
*.so

# Distribution / packaging
*.egg
*.egg-info/
dist/
build/
.eggs/

# Virtual environments
.venv/
venv/
env/

# Testing
.pytest_cache/
.coverage
htmlcov/

# Editors
.vscode/
.idea/
*.swp
*~

# OS
.DS_Store
Thumbs.db
88 changes: 87 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,87 @@
# Opera_tools
# Opera_tools

Python tools for working with [OPERA](https://www.jpl.nasa.gov/go/opera) SAR/InSAR product files.

## Features

* **Spatial subsetting** – Clip OPERA product files to a geographic bounding box.
* Supports **GeoTIFF** (`.tif`, `.tiff`) products (RTC, DSWx, …)
* Supports **HDF5** (`.h5`, `.hdf5`, `.nc`) products (CSLC, DISP-S1, …)

## Installation

```bash
pip install -r requirements.txt
pip install -e .
```

Or directly from GitHub:

```bash
pip install git+https://github.com/geodesymiami/Opera_tools.git
```

## Quick start

### Command-line

```bash
# Subset one or more GeoTIFF files to a bounding box
opera_subset --bbox -118.5 33.5 -117.5 34.5 product.tif

# Subset multiple files and write results to a directory
opera_subset --bbox -118.5 33.5 -117.5 34.5 -o ./subset/ *.tif *.h5

# Custom output suffix
opera_subset --bbox -118.5 33.5 -117.5 34.5 --suffix _cropped product.h5
```

Positional and optional arguments:

```
usage: opera_subset [-h] --bbox MIN_LON MIN_LAT MAX_LON MAX_LAT
[-o DIR] [--suffix SUFFIX]
FILE [FILE ...]

positional arguments:
FILE Input OPERA product file(s) (.tif, .tiff, .h5, .hdf5, .nc).

optional arguments:
--bbox MIN_LON MIN_LAT MAX_LON MAX_LAT
Geographic bounding box in WGS 84 degrees.
-o DIR, --outdir DIR Output directory (default: current directory).
--suffix SUFFIX Suffix appended to each output filename (default: _subset).
```

### Python API

```python
from opera_tools import subset_opera_file, subset_opera_files

# Subset a single file
success = subset_opera_file(
"OPERA_L2_RTC-S1_T064-135524-IW1_20231101T015038Z_20231101T101117Z_S1A_30_v1.0.tif",
"output_subset.tif",
bbox=(-118.5, 33.5, -117.5, 34.5), # (min_lon, min_lat, max_lon, max_lat)
)

# Subset a batch of files
written = subset_opera_files(
input_files=["file1.tif", "file2.h5"],
output_dir="./subset/",
bbox=(-118.5, 33.5, -117.5, 34.5),
)
```

## Dependencies

* [numpy](https://numpy.org/)
* [rasterio](https://rasterio.readthedocs.io/) – GeoTIFF subsetting
* [h5py](https://www.h5py.org/) – HDF5 subsetting

## Running tests

```bash
pip install pytest
pytest tests/
```
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
numpy
rasterio
h5py
30 changes: 30 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from setuptools import setup, find_packages

setup(
name="opera-tools",
version="0.1.0",
description="Tools for working with OPERA SAR/InSAR product files",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="geodesymiami",
url="https://github.com/geodesymiami/Opera_tools",
package_dir={"": "src"},
packages=find_packages(where="src"),
python_requires=">=3.8",
install_requires=[
"numpy",
"rasterio",
"h5py",
],
entry_points={
"console_scripts": [
"opera_subset=opera_tools.subset:main",
],
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Topic :: Scientific/Engineering :: GIS",
"Topic :: Scientific/Engineering :: Image Processing",
],
)
5 changes: 5 additions & 0 deletions src/opera_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""opera_tools: tools for working with OPERA SAR/InSAR product files."""

from .subset import subset_opera_file, subset_opera_files

__all__ = ["subset_opera_file", "subset_opera_files"]
Loading
Loading