Skip to content

bartromgens/climatemaps

Repository files navigation

climatemaps

An interactive web application for visualizing global historical climate data and future climate projections. It show temperature, precipitation, and other climate variables with support for multiple climate scenarios (SSP1-2.6, SSP2-4.5, SSP3-7.0, SSP5-8.5) and time periods (2020-2100).

Precipitation predictions example

Demo

openclimatemap.org

Data

Historic

Projections (predictions)

Other (not used)

Development

Dependencies

GDAL

GDAL is needed for the gdal2tiles.py script that creates map-tiles from a single image (matplotlib plot).

Install GDAL with conda to prevent the need to install a hugh number of system level dependencies:

conda install -c conda-forge gdal==3.11.0
Tippecanoe

WARNING: tippecanoe 1.19.1 is the latest version that produces valid GeoJSON due to issue mapbox/tippecanoe#652

TODO: migrate to active fork https://github.com/felt/tippecanoe

sudo apt install libsqlite3-dev
git clone https://github.com/mapbox/tippecanoe.git
cd tippecanoe
git checkout tags/1.19.1
make -j
make install

tileserver-gl

npm install -g tileserver-gl

Run

Create contour data

Run:

python scrips/create_contour.py [--month=1] [-dataset-type=historic]

to create contour and raster mbtiles.

Create tileserver config

python scripts/create_tileserver_config.py

to generate the tileserver config.

Run the backend (FastAPI server)

uvicorn api.main:app --reload

Run the tileserver (tileserver-gl)

tileserver-gl --config tileserver_config_dev.json --port 8080

Or with auto-restart on config changes (requires nodemon: npm install -g nodemon):

nodemon --watch tileserver_config_dev.json --exec "tileserver-gl --config tileserver_config_dev.json --port 8080"

Run the client (Angular)

In ./client run:

ng serve

Or run against the openclimatemap.org API and tileserver:

ng serve --configuration=production-backend

Alternative: Docker Compose (recommended for production-like setup)

Start both the API server and tileserver using Docker Compose:

docker compose up -d

This will start:

  • API server on localhost:8000
  • Tileserver on localhost:8080

To view logs:

docker compose logs -f

To stop the services:

docker compose down

Note: Make sure you have already created the tiles and tileserver config before starting the services.

Tests

Run:

pytest

Build and deploy (to openclimatemap.org)

Everything

Build and deploy client and backend:

bash scripts/deploy.sh

TODO: include create tiles, create config and upload tiles

Client

Deploy the client angular app:

bash scripts/deploy_client.sh

API and TileServer

bash scripts/deploy_backend.sh

Logs

View logs for the API (FastAPI):

docker compose logs -f api

View logs for the TileServer:

docker compose logs -f tileserver

Upload tiles (optional)

If you have locally created tiles, upload them to the server with:

rsync -avP data/tiles openclimatemap.org:/home/bart/climatemaps/data/

About

Global monthly climate data, historic and predictions, on an interactive map

Topics

Resources

License

Stars

Watchers

Forks

Contributors