Skip to content

Running the step

Goal

Run the command line tool in a Python virtual environment.

Lab

This step has a dedicated lab available at /workspace/quickwin/practice-labs/Application.ipynb

Step 1 - Configure the workspace

The results produced will be available in the local folder /workspace/quickwin/runs

terminal
1
2
3
4
export WORKSPACE=/workspace/quickwin
export RUNTIME=${WORKSPACE}/runs
mkdir -p ${RUNTIME}
cd ${RUNTIME}

Step 2 - Create the Python virtual environment

The required Python modules are installed using pip:

terminal
1
2
3
python3 -m venv env_water_bodies
source env_water_bodies/bin/activate
pip install --no-cache-dir rasterio click pystac loguru pyproj shapely scikit-image rio_stac

Step 3 - Run the water bodies detection

The command line tool is invoked with:

terminal
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
WORKSPACE=/workspace/quickwin
RUNTIME=${WORKSPACE}/runs
mkdir -p ${RUNTIME}
cd ${RUNTIME}

python \
    ${WORKSPACE}/water-bodies/command-line-tools/detect-water-body/app.py \
    --input-item "https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items/S2B_10TFK_20210713_0_L2A" \
    --aoi "-121.399,39.834,-120.74,40.472" \
    --epsg "EPSG:4326" \
    --band green \
    --band nir 

Step 4 - Clean-up

The Python virtual environment is no longer needed.

terminal
1
2
deactivate
rm -fr env_water_bodies

Expected outcome

The folder /workspace/quickwin/runs contains:

(base) jovyan@jupyter-mrossi--training:~/quickwin/runs$ tree .
.
├── S2B_10TFK_20210713_0_L2A
│   ├── S2B_10TFK_20210713_0_L2A.json
│   └── otsu.tif
├── catalog.json
└── otsu.tif

1 directory, 4 files