cogeotiff / rio-cogeo

Cloud Optimized GeoTIFF creation and validation plugin for rasterio
https://cogeotiff.github.io/rio-cogeo/
BSD 3-Clause "New" or "Revised" License
308 stars 42 forks source link

Unexpected GET Requests Count with web-optimized COG #275

Closed tebben closed 7 months ago

tebben commented 7 months ago

I'm trying to optimize a COG for our Cesium Terrain on Demand service where we request tiles using rio-tiler with the WGS1984Quad tiling schema. I warp a tiff to 4326 and run the the create command with -w to create a COG with internal tiles aligned to the TMS.

gdalwarp -t_srs EPSG:4326 R_09BN2.TIF R_09BN2_4326.TIF
rio cogeo create R_09BN2_4326.TIF R_09BN2_4326_cog.tif --cog-profile deflate --blocksize 256 --overview-blocksize 256 --tms ./WGS1984Quad.json -w

The output works fine in our service but if I profile getting a tile with tilebench (changed to work with WGS1984Quad) it reports 3 GET requests while i would expect 2: head and tile data.

tilebench profile http://localhost:3000/R_09BN2_4326_cog.tif --tile 17-134586-26855 --add-kernels | jq
{
  "HEAD": {
    "count": 1
  },
  "GET": {
    "count": 3,
    "bytes": 212992,
    "ranges": [
      "0-65535",
      "287064064-287211519"
    ]
  },
  "WarpKernels": [],
  "Timing": 0.02144479751586914
}

Running this for a random tile on zoom 16 even reports Get->Count: 4

tilebench profile http://localhost:3000/R_09BN2_4326_cog.tif --tile 16-67300-13416 --add-kernels | jq
{
  "HEAD": {
    "count": 1
  },
  "GET": {
    "count": 4,
    "bytes": 792654,
    "ranges": [
      "0-65535",
      "41233096-41604119",
      "45029981-45386074"
    ]
  },
  "WarpKernels": [],
  "Timing": 0.024923324584960938
}

rio cogeo info reports the following info.

Driver: GTiff
File: R_09BN2_4326_cog.tif
COG: True
Compression: DEFLATE
ColorSpace: None

Profile
    Width:            14336
    Height:           10752
    Bands:            1
    Tiled:            True
    Dtype:            float32
    NoData:           3.4028234663852886e+38
    Alpha Band:       False
    Internal Mask:    False
    Interleave:       BAND
    ColorMap:         False
    ColorInterp:      ('gray',)
    Scales:           (1.0,)
    Offsets:          (0.0,)

Geo
    Crs:              EPSG:4326
    Origin:           (4.788665771484176, 53.16146850585942)
    Resolution:       (5.36441802978515e-06, -5.36441802978515e-06)
    BoundingBox:      (4.788665771484176, 53.10379028320317, 4.865570068359176, 53.16146850585942)
    MinZoom:          12
    MaxZoom:          18

Image Metadata
    AREA_OR_POINT: Area
    OVR_RESAMPLING_ALG: NEAREST
    TILING_SCHEME_NAME: WorldCRS84Quad
    TILING_SCHEME_ZOOM_LEVEL: 17

Image Structure
    COMPRESSION: DEFLATE
    INTERLEAVE: BAND
    LAYOUT: COG

Band 1
    ColorInterp: gray

IFD
    Id      Size           BlockSize     Decimation           
    0       14336x10752    256x256       0
    1       7168x5376      256x256       2
    2       3584x2688      256x256       4
    3       1792x1344      256x256       8
    4       896x672        256x256       16
    5       448x336        256x256       32
    6       224x168        256x256       64

I also tried updating rio-tiler in tilebench and adding align_bounds_with_dataset to the tile request but that didn't make any difference.

Am i doing something wrong? is the GET count as expected? Or is there something else going on?