This repo contains scripts relevant to the development of new LULC datasets for the UN Small Island Developing States (SIDS).
The ldn folder contains an installable package.
We will make GeoMedian/Geomad for all tiles that cover the SIDS and Pacific countries, for the years 2000-2024. Then we will create training data from existing products (for 2020). Then we will train a model and predict for all SIDS and Pacific countries for all years.
- Install GDAL (and its Python bindings) via Homebrew
brew upgrade gdal- Install Rust (for datacube-compute):
brew install rustup
rustup-init
export PATH="$HOME/.cargo/bin:$PATH"- Install Poetry if you don't have it already:
pip install poetry- Create and activate a Poetry virtual environment pointing at Homebrew's Python 3.12 and install dependencies:
This installs main group. Deps like
cogeo-mosaicandboto3are in both main and visualisation group.
poetry env use $(brew --prefix python@3.12)/bin/python3.12
poetry installFor development dependencies:
poetry install --with devFor visualisation dependencies:
poetry install --no-root --only visualisation- Run the CLI tool:
poetry run ldn --help
poetry run make geomad-singaporeRun: poetry add --dev pytest
Others: poetry add "dep-tools@git+https://github.com/digitalearthpacific/dep-tools.git" poetry add "datacube-compute@git+https://github.com/auspatious/datacube-compute.git"
Simply run: poetry run pytest or for a specific file: poetry run pytest ldn/tests/test_mosaic.py
Formats Python, YAML, and JSON.
To use pre-commit to automatically run ruff, and other checks on each commit, make sure the development dependencies are installed and then run:
poetry run pre-commit installNote that you will need to run poetry run pre-commit run --all-files if any of the hooks in .pre-commit-config.yaml change.
You can run these:
poetry run ldn --helppoetry run ldn versionpoetry run ldn grid list-countriesormake grid-list-countries
Future commands could look like:
- Run our random forest model to predict/classify a tile:
ldn process --tile-id xxx. - Get a class:
ldn grid <class_name>e.g. forest or grassland
To build the Docker image locally using Buildx, run:
docker buildx build . --tag ldn-lulc:latestOnce built, you can run any command in the container:
docker run --rm ldn-lulc:latest ldn grid list-countries
A tile server for viewing GeoMedian/GeoMAD and predicted LULC mosaics, built with TiTiler and deployed as an AWS Lambda behind API Gateway.
- AWS credentials configured (
aws configureor environment variables) - Terraform >= 1.5
- Docker
From the project root:
poetry install --with visualisation # Needed for ldn make-mosaics command.
bash visualisation/deploy.shThis will:
- Build mosaic JSON files and upload to S3
- Create an ECR repository (if it doesn't exist)
- Build and push the Docker image
- Deploy the Lambda + API Gateway via Terraform
poetry install --with visualisation
poetry run uvicorn visualisation.app:app --host 0.0.0.0 --port 8081 --reload