1

So I installed Terracotta. They have this weird system for naming their files https://terracotta-python.readthedocs.io/en/latest/concepts.html#data-model. So I converted my file into there optimized raster(as stated in the docs) and gave it a filename similar to how they have their files (S2_denmark_20180524_B03.tif) and then had to run :

terracotta serve -r {}_{date}_{band}.tif

in the folder in which my renamed file was.

When I went http://localhost:5001/rgb/2018061/preview.png?r=VV&g=VV&b=VV (my file is called S2_2018061_VV.tif) I got a B&W version of my geoTIFF. I know the bands are meant to be like different colors or something, What band should I pick to get a RGB image instead?

I really don't understand the terracotta filename syntax in general like what exactly are this bands meant for and the type S2. The docs were not very helpful in explaining this and research TIFF bands has not been very helpful.

Terracotta docs https://terracotta-python.readthedocs.io/en/latest/index.html

tiff This the gdalinfo output on the file (before the cloud optimize) enter image description here This the gdalinfo output on the file (after the cloud optimize) enter image description here

4
  • 1
    Welcome to GIS SE ! Can you provide some informations about your raster S2_2018061_VV.tif ? Like gdalinfo S2_2018061_VV.tif ? If it's a RGB raster, it will have 3 bands : one for red, one for green and one for blue. I think you have to create 3 geotiff raster files, one for each band, use for example gdal_translate, see: gis.stackexchange.com/a/62134/93097 Commented May 27, 2022 at 8:47
  • 1
    After the cloud optimize, the geotiff has only one band (= Gray), so you can't split it into multiple band and can't display it in colors with Terracotta. So for me, the question is : what do exactly the cloud optimization ? Commented May 27, 2022 at 12:00
  • @J.Monticolo um they recommended it in the docs, i can try without it see if it works From the docs: Note Terracotta benefits greatly from the cloud-optimized GeoTiff format. If your raster files are not cloud-optimized or you are unsure, you can preprocess them with terracotta optimize-rasters.
    – jagrat
    Commented May 27, 2022 at 12:05
  • 1
    I think I understand, as Terracotta works on single band rasters, it optimizes only one band, so for me, split your original raster into 3 bands, optimize each one and serve them. Then, in the url, call each band for the corresponding color, for me you'll have a raster in RGB color. Commented May 27, 2022 at 12:08

1 Answer 1

1

Terracotta expects your files to have one band each.

The file you started with had three (and apparently they are R, G, B and Alpha). The file you then used had only one so no true color information is left. https://terracotta-python.readthedocs.io/en/latest/cli-commands/optimize-rasters.html explicitly says "Note that all rasters may only contain a single band." so you'd either have to split your file into separate rasters again or re-download the scene at the source where it is probably available as separate files.

Your URL asks for the same file for each band so you are using the same value per pixel three times. Same value on R, G and B means grey scale.

To make it work you need to have one file per band. Name them accordingly and specify them in the request like shown on https://terracotta-python.readthedocs.io/en/latest/concepts.html#data-model

A common pattern, matching Sentinel-2 data standards, would be "B04" for red, "B03" for green and "B02" for blue. Then you can specify them in your URLs: ...?r=B04&g=B03&b=B02

PS: "VV" is used for polarisation bands, I assume you used it by mistake.

3
  • I used gdal_translate -b 1 input.tif output.tif to separate my original tiff into bands and then used terracotta optimize-rasters *.tif -o optimized/ to optimize them. I was able to get a rgb image (gdalinfo on the optimized files had the following output: Band 1 Block=256x256 Type=Byte, ColorInterp=Gray Overviews: 21050x15551, 10525x7776, 5263x3888, 2632x1944, 1316x972,658x486,329x243, 165x122 Mask Flags: PER_DATASET ). The terracotta server also gave the flowing warning : S2_2018061_B04.tif does not have a valid nodata value, and does not contain an alpha band. No data will be masked.
    – jagrat
    Commented May 27, 2022 at 16:40
  • You need to do one gdal_translate per band and name your files accordingly. -b 1 -> "B04" and so on. Commented May 27, 2022 at 17:17
  • 1
    yes i did do that i got 4 different files (for r g b and one for alpha) and now everything works as expected (i got a rgb preview and rgb tiles), i was just mentioning some things i found odd for future references
    – jagrat
    Commented May 27, 2022 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.