Skip to content

Condition Layers

Elsie L edited this page Mar 7, 2023 · 1 revision

Build data layer tiles

As an optimization, the Planscape frontend uses pre-computed tiles for the data layers. These tiles could be (and were originally) computed from the rasters stored in the Planscape database, but that takes too long and makes the frontend hard to use. Tiles (which are .png files) are computed from raster files and stored in S3 instead, and the frontend accesses the tile files directly

WARNING: It takes at least two days to compute and upload the RRK rasters for one region, so start ahead.

There are two steps. The second step can overlap the first step once you have some data from the first. The example below creates and uploads the tiles for the Sierra Nevada region.

Create the tiles

Suppose the raster files are on your local machine in a directory $DATA_DIR. From the src/planscape directory (the Django application), run

python manage.py create_tiles $DATA_DIR/data --region_name=sierra_cascade_inyo --colormap=turbo --no-dry_run

The path to the individual files within this directory come from "filepath" entries in

src/config/conditions.json

without the ".tif" extensions, e.g.,

"filepath: "sierra_nevada/biodiversity/focal_species/CSO_suitablehabitat_combined_300m"

The output from this command is written to the $DATA_DIR/tiles directory, e.g.,

tiles/
  sierra_nevada/
    biodiversity/
      focal_species/
        CSO_suitablehabitat_combined_300m/
          10/   # tiles at zoom level 10
          11/   # tiles at zoom level 11
          12/   # tiles at zoom level 12
          13/   # tiles at zoom level 13
           7/   # tiles at zoom level 7
           8/   # tiles at zoom level 8
           9/   # tiles at zoom level 9

There are options for overriding the zoom levels, etc. See

python manage.py create_tiles --help

for more information.

Upload the tiles to S3

In a different terminal window, run the following commands

aws configure set default.s3.max_concurrent_requests 50
aws s3 sync --exclude '*.html' --exclude '*.vrt' --exclude '*.mapml' --exclude '*.tgz' s3://planscape-tiles/sierra_nevada