Skip to content

Running the step

Goal

Run the crop step in a Python virtual environment.

Step 1 - Configure the workspace

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

terminal
1
2
3
4
export WORKSPACE=/workspace/app-package-training-bids23
export RUNTIME=/workspace/runs
mkdir -p ${RUNTIME}
cd ${RUNTIME}
source /workspace/app-package-training-bids23/scripts/setup.sh

Step 2 - Create the Python virtual environment

The required Python modules are installed using pip:

terminal
1
2
3
python -m venv env_crop
source env_crop/bin/activate
pip install --no-cache-dir rasterio click pystac loguru pyproj shapely 
source ${WORKSPACE}/scripts/crop_env.sh

Step 3 - Crop the green band

The command line tool is invoked to crop the green band:

terminal
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
export WORKSPACE=/workspace/app-package-training-bids23
export RUNTIME=/workspace/runs
mkdir -p ${RUNTIME}
cd ${RUNTIME}

python \
    ${WORKSPACE}/water-bodies/command-line-tools/crop/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 
source ${WORKSPACE}/scripts/crop_green.sh

Step 4 - Crop the NIR band

The command line tool is invoked to crop the NIR band:

terminal
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
export WORKSPACE=/workspace/app-package-training-bids23
export RUNTIME=/workspace/runs
mkdir -p ${RUNTIME}
cd ${RUNTIME}

python \
    ${WORKSPACE}/water-bodies/command-line-tools/crop/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 nir 
source ${WORKSPACE}/scripts/crop_nir.sh

Step 5 - Clean-up

The Python virtual environment is no longer needed.

terminal
1
2
deactivate
rm -fr env_crop
source ${WORKSPACE}/scripts/crop_deactivate.sh

Expected outcome

The folder /workspace/runs contains:

(base) jovyan@coder-mrossi:~/runs$ tree .
.
├── crop_green.tif
└── crop_nir.tif

0 directories, 2 files