Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yannforget committed Aug 22, 2018
0 parents commit be90ea7
Show file tree
Hide file tree
Showing 11 changed files with 919 additions and 0 deletions.
104 changes: 104 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Yann Forget

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.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include README.md
include LICENSE.txt
include asarapi/certs.pem
132 changes: 132 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
## Description

**ASARapi** is a simple Python command-line program that allows you to search the [ESA Online Catalogue](http://esar-ds.eo.esa.int/sxcat) for SAR images produced by the [ERS-1](https://earth.esa.int/web/sppa/mission-performance/esa-missions/ers-1) (1991-2000), [ERS-2](https://earth.esa.int/web/sppa/mission-performance/esa-missions/ers-2) (1995-2011), or [Envisat](https://earth.esa.int/web/sppa/mission-performance/esa-missions/envisat) (2002-2012) satellites and to download them.

The following collections are supported:

* `ASA_IMP_1P`: Level 1 products for ENVISAT ASAR Image Mode Precision Image.
* `ASA_IMS_1P`: Level 1 products for ENVISAT ASAR Image Mode Single-Look
Complex.
* `SAR_IMP_1P`: Level 1 products for ERS SAR Precision Image.
* `SAR_IMS_1P`: Level 1 products for ERS SAR Single-Look Complex.

## Installation

**ASARapi** can be installed using `pip`.

```sh
pip install asarapi
```

## Usage

### Sync database

**ASARapi** is designed to work with a local SQLite dump of the ESA Online Catalogue in order to speed up spatial queries. Therefore, the database must be downloaded before using the program by running the `sync` subcommand.

```bash
asarapi sync
```

The file will be stored in your user data directory, e.g. `~/.local/share/asarapi` on Linux, `/Users/<user>/Library/Application Support/asarapi` on OSX, or `C:\Users\<user>\AppData\Local\asarapi` on Windows.

Please see [`yannforget/esa-online-catalogue`](https://github.com/yannforget/esa-online-catalogue) for further details regarding the scraping of the ESA Online Catalogue.

### Search the catalog

#### Usage

```
Usage: asarapi search [OPTIONS]
Search for ERS and Envisat products.
Options:
--geojson PATH GeoJSON footprint.
--start TEXT Start date (YYYY-MM-DD).
--stop TEXT Stop date (YYYY-MM-DD).
--latlon FLOAT... Decimal lat/lon.
--bounds FLOAT... (max_lat, max_lon, min_lat, min_lon).
--platform TEXT Platform of interest (ERS or ENVISAT, default = all)
--product TEXT Product type (Precision (default) or Single-Look).
--polarisation TEXT Polarisation channels (default = all).
--orbit [ascending|descending] Orbit direction (default = all).
--contains Footprint contained by input geom (default = False).
--limit INTEGER Max. number of results (default = 500).
--output PATH Output CSV file.
--help Show this message and exit.
```

By default, `asarapi search` will output the product IDs that satisfy the query. A CSV file containing the metadata and the footprint of each scene can be generated with the `--output` option.

#### Examples

```sh
# All available products between 1995 and 1999 according to an area of interest
# defined in a GeoJSON file.
asarapi search --start 1995-01-01 --stop 1999-12-31 --geojson aoi.geojson

# All available products between 1995 and 1999 that intersect the given location
asarapi search --start 1995-01-01 --stop 1999-12-31 --latlon 16.27 -0.04

# Envisat Single-Look Complex images for a given AOI
asarapi search --start 2002-01-01 --stop 2005-01-01 --geojson aoi.geojson \
--platform envisat --product single-look --orbit descending

# Write the result of a query in a .CSV file
asarapi search --start 1995-01-01 --stop 1999-12-31 --geojson aoi.geojson \
--output products.csv
```

### Download a product

#### Usage

To download products, you will need [ESA SSO](https://eo-sso-idp.eo.esa.int) credentials. Register for free [here](https://eo-sso-idp.eo.esa.int/idp/umsso20/registration).

```sh
Usage: asarapi download [OPTIONS] PRODUCT

Download an ERS or Envisat product.

Options:
-u, --username TEXT ESA SSO username.
-p, --password TEXT ESA SSO password.
-o, --outputdir PATH Output directory.
--help Show this message and exit.
```

#### Example

```sh
asarapi download -u <esa_sso_username> -p <esa_sso_password> \
"SAR_IMP_1PNESA20030215_091621_00000015A081_00465_40900_0000"
```

## API

**ASARapi** can also be used in custom Python scripts:

```python
from datetime import datetime
from shapely.geometry import Point
from asarapi.catalog import query
from asarapi.download import log_in, log_out, request_download

username = esa_sso_username
password = esa_sso_password
output_dir = '../data'
location = Point(16.84, -0.04)

results = query(
area=location.wkt,
start=datetime(1999, 1, 1),
stop=datetime(2002, 1, 1),
orbit='ascending'
)

session = log_in(username, password)
for product_id in results.index:
request_download(session, product_id, output_dir)
log_out(session)
```
Empty file added asarapi/__init__.py
Empty file.
Loading

0 comments on commit be90ea7

Please sign in to comment.