Skip to content

auspatious/ldn-lulc

Repository files navigation

Land Degradation Neutrality - Land Use/Land Cover

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.

Quickstart

  1. Install GDAL (and its Python bindings) via Homebrew
  brew upgrade gdal
  1. Install Rust (for datacube-compute):
brew install rustup
rustup-init
export PATH="$HOME/.cargo/bin:$PATH"
  1. Install Poetry if you don't have it already:
  pip install poetry
  1. Create and activate a Poetry virtual environment pointing at Homebrew's Python 3.12 and install dependencies: This installs main group. Deps like cogeo-mosaic and boto3 are in both main and visualisation group.
  poetry env use $(brew --prefix python@3.12)/bin/python3.12
  poetry install

For development dependencies:

   poetry install --with dev

For visualisation dependencies:

   poetry install --no-root --only visualisation
  1. Run the CLI tool:
   poetry run ldn --help
   poetry run make geomad-singapore

To add a dependency

Run: 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"

To run tests

Simply run: poetry run pytest or for a specific file: poetry run pytest ldn/tests/test_mosaic.py

Pre-commit hooks

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 install

Note that you will need to run poetry run pre-commit run --all-files if any of the hooks in .pre-commit-config.yaml change.

Running Commands

You can run these:

  • poetry run ldn --help
  • poetry run ldn version
  • poetry run ldn grid list-countries or make 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

Building and Running the Docker Image

To build the Docker image locally using Buildx, run:

docker buildx build . --tag ldn-lulc:latest

Once built, you can run any command in the container:

docker run --rm ldn-lulc:latest ldn grid list-countries

Visualisation

A tile server for viewing GeoMedian/GeoMAD and predicted LULC mosaics, built with TiTiler and deployed as an AWS Lambda behind API Gateway.

Prerequisites

  • AWS credentials configured (aws configure or environment variables)
  • Terraform >= 1.5
  • Docker

Deploy

From the project root:

poetry install --with visualisation # Needed for ldn make-mosaics command.
bash visualisation/deploy.sh

This will:

  1. Build mosaic JSON files and upload to S3
  2. Create an ECR repository (if it doesn't exist)
  3. Build and push the Docker image
  4. Deploy the Lambda + API Gateway via Terraform

Run locally

poetry install --with visualisation
poetry run uvicorn visualisation.app:app --host 0.0.0.0 --port 8081 --reload

Current deployment

https://mmufb4pjqf.execute-api.us-west-2.amazonaws.com/

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors