Skip to content

Commit

Permalink
document cog generation and requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Nov 29, 2023
1 parent 388871d commit 9b7b85c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ docker run --rm -ti -v $PWD:/host --workdir /host ghcr.io/osgeo/gdal \

Full documentation is available at [gdal.org/drivers/vector/pmtiles.html](https://gdal.org/drivers/vector/pmtiles.html).


## COG conversion
Raster images should be converted a 4 bands RGBA GEOTiff using EPSG:3857.

If you have a single-band greyscale GEOTiff you can use `generate_cog.sh` to produce a valid Cloud Optimized GEOTiff.

**NOTE**: COG layers are static, style must be pre-applyied.


## Running the webapp

The only requirement is having a web server which supports HTTP bytes serving/ranged requests, such as NGINX.
Expand Down
13 changes: 13 additions & 0 deletions generate_cog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -ex

export MASK=$(mktemp .cog.XXXXXXX.tif -p .)
export NORMALIZED=$(mktemp .cog.XXXXXXX.tif -p .)
export RGBA=$(mktemp .cog.XXXXXXX.tif -p .)

gdal_translate -scale 0 1 255 255 $1 $MASK
gdal_translate -scale 0 1 0 255 $1 $NORMALIZED
gdal_merge.py -separate -o $RGBA -of GTiff $NORMALIZED $NORMALIZED $NORMALIZED $MASK
gdal_translate $RGBA $2 -of COG -co TARGET_SRS=EPSG:3857 -co ADD_ALPHA=NO -co COMPRESS=LZW -co LEVEL=9
rm $MASK $NORMALIZED $RGBA;

0 comments on commit 9b7b85c

Please sign in to comment.