Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imagery is always reprojected, even if it is already correctly projected and tile aligned #431

Closed
Plantain opened this issue Feb 11, 2022 · 16 comments
Labels
bug Something isn't working

Comments

@Plantain
Copy link

Plantain commented Feb 11, 2022

Expected behaviour: If a COG is created with TILING_SCHEME=GoogleMapsCompatible, and the serving environment is EPSG:3857, because the COG's tiles are aligned and the projection already matches, titiler should be able to do everything it needs with two reads (metadata + tile) and zero reprojection. It should be very fast because it's only two reads and no reprojection.

Actual behaviour:
I suspected that some reprojection was happening because it appeared as though there was some loss in fidelity between source and the browser, and that it was just as slow (~1-2 seconds...) as if the source imagery was in a totally different projection.
Turning all the debugging up to the maximum, it looks like it is doing multiple reads and projection.

Problem:
Does GDAL not align the COG properly, or does titiler read more than it needs to?

START RequestId: 95949854-f0ec-43e7-b38a-3346139b6777 Version: $LATEST
[INFO]	2022-02-11T06:39:40.024Z	95949854-f0ec-43e7-b38a-3346139b6777	Found credentials in environment variables.
tile()
[INFO]	2022-02-11T06:39:40.036Z	95949854-f0ec-43e7-b38a-3346139b6777	Found credentials in environment variables.
[Fri Feb 11 06:39:40 2022].0612, 8.4825: GTiff: ScanDirectories()
[Fri Feb 11 06:39:40 2022].0615, 8.4828: GTiff: Opened band mask.
[Fri Feb 11 06:39:40 2022].0616, 8.4830: GTiff: Opened 16384x12544 overview.
[Fri Feb 11 06:39:40 2022].0618, 8.4831: GTiff: Opened 8192x6272 overview.
[Fri Feb 11 06:39:40 2022].0619, 8.4832: GTiff: Opened 4096x3136 overview.
[Fri Feb 11 06:39:40 2022].0620, 8.4834: GTiff: Opened 2048x1568 overview.
[Fri Feb 11 06:39:40 2022].0621, 8.4835: GTiff: Opened 1024x784 overview.
[Fri Feb 11 06:39:40 2022].0623, 8.4836: GTiff: Opened 512x392 overview.
[Fri Feb 11 06:39:40 2022].0624, 8.4837: GTiff: Opened 256x196 overview.
[Fri Feb 11 06:39:40 2022].0625, 8.4838: GTiff: Opened band mask for 16384x12544 overview.
[Fri Feb 11 06:39:40 2022].0627, 8.4840: GTiff: Opened band mask for 8192x6272 overview.
[Fri Feb 11 06:39:40 2022].0628, 8.4841: GTiff: Opened band mask for 4096x3136 overview.
[Fri Feb 11 06:39:40 2022].0629, 8.4842: GTiff: Opened band mask for 2048x1568 overview.
[Fri Feb 11 06:39:40 2022].0630, 8.4844: GTiff: Opened band mask for 1024x784 overview.
[Fri Feb 11 06:39:40 2022].0631, 8.4845: GTiff: Opened band mask for 512x392 overview.
[Fri Feb 11 06:39:40 2022].0633, 8.4846: GTiff: Opened band mask for 256x196 overview.
[INFO]	2022-02-11T06:39:40.073Z	95949854-f0ec-43e7-b38a-3346139b6777	Found credentials in environment variables.
[INFO]	2022-02-11T06:39:40.085Z	95949854-f0ec-43e7-b38a-3346139b6777	Found credentials in environment variables.
[INFO]	2022-02-11T06:39:40.095Z	95949854-f0ec-43e7-b38a-3346139b6777	Found credentials in environment variables.
[Fri Feb 11 06:39:40 2022].0970, 8.5183: WARP: SetAlphaMax: AlphaMax not set.
[Fri Feb 11 06:39:40 2022].0975, 8.5188: S3: Downloading 61005463-61051307 
[Fri Feb 11 06:39:40 2022].0976, 8.5189: S3: Downloading 62028729-62076389 
* Couldn't find host s3.amazonaws.com in the (nil) file; using defaults
* Found bundle for host s3.amazonaws.com: 0x7f2eac1374b0 [serially]
* Server doesn't support multiplex (yet)
*   Trying 52.217.232.104:443...
* Hostname 's3.amazonaws.com' was found in DNS cache
*   Trying 52.217.232.104:443...
* Connected to s3.amazonaws.com (52.217.232.104) port 443 (#0)
> GET /himawari.tiff HTTP/1.1
Host: s3.amazonaws.com
Accept: */*
Range: bytes=61005463-61051307
> GET /himawari.tiff HTTP/1.1
Host: s3.amazonaws.com
Accept: */*
Range: bytes=62028729-62076389
< HTTP/1.1 206 Partial Content
< Date: Fri, 11 Feb 2022 06:39:41 GMT
< Last-Modified: Fri, 11 Feb 2022 06:38:38 GMT
< ETag: "2298300fcbdf6d24e0f722e1065f6c1a"
< Accept-Ranges: bytes
< Content-Range: bytes 62028729-62076389/72430193
< Content-Type: binary/octet-stream
< Server: AmazonS3
< Content-Length: 47661
< 
* Connection #1 to host s3.amazonaws.com left intact
* Mark bundle as not supporting multiuse
< HTTP/1.1 206 Partial Content
< Date: Fri, 11 Feb 2022 06:39:41 GMT
< Last-Modified: Fri, 11 Feb 2022 06:38:38 GMT
< ETag: "2298300fcbdf6d24e0f722e1065f6c1a"
< Accept-Ranges: bytes
< Content-Range: bytes 61005463-61051307/72430193
< Content-Type: binary/octet-stream
< Server: AmazonS3
< Content-Length: 45845
< 
* Connection #0 to host s3.amazonaws.com left intact
[Fri Feb 11 06:39:40 2022].1632, 8.5846: S3: Download completed
[Fri Feb 11 06:39:40 2022].1789, 8.6002: GDAL: GDALWarpKernel()::GWKRealCase() Src=29181,15357,262x134 Dst=0,0,256x128
[Fri Feb 11 06:39:40 2022].2199, 8.6412: GDAL: GDALWarpKernel()::GWKRealCase() Src=29181,15485,262x134 Dst=0,128,256x128
GDAL: Flushing dirty blocks: 0...10...20...30...40...50...60...70...80...90...100 - done.
[Fri Feb 11 06:39:40 2022].2554, 8.6767: GDAL: GDALClose(/vsis3/himawari.tiff, this=0x7f2eac0f7910)
[INFO]	2022-02-11T06:39:40.271Z	95949854-f0ec-43e7-b38a-3346139b6777	Found credentials in environment variables.
ERROR 4: `/vsimem/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686.tif' not recognized as a supported file format.
[Fri Feb 11 06:39:40 2022].2728, 8.6941: PROJ: pj_open_lib(proj.db): call fopen(/var/task/rasterio/proj_data/proj.db) - succeeded
[Fri Feb 11 06:39:40 2022].3359, 8.7573: GDAL: GDALClose(/vsimem/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686.tif, this=0x7f2eb418b860)
[Fri Feb 11 06:39:40 2022].3360, 8.7573: GDAL: GDALClose(temp, this=0x7f2eac11a270)
[Fri Feb 11 06:39:40 2022].3361, 8.7574: GDAL: GDALOpen(/vsimem/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686.tif, this=0x7f2eb418b860) succeeds as PNG.
[Fri Feb 11 06:39:40 2022].3361, 8.7574: GDAL: GDALClose(/vsimem/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686.tif, this=0x7f2eb418b860)
[Fri Feb 11 06:39:40 2022].3361, 8.7575: GDAL: GDALOpen(/vsimem/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686.tif, this=0x7f2eb418b860) succeeds as PNG.
[Fri Feb 11 06:39:40 2022].3361, 8.7575: GDAL: GDALDefaultOverviews::OverviewScan()
[Fri Feb 11 06:39:40 2022].3362, 8.7575: GDAL: GDALClose(/vsimem/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686/7a6b20f0-a9f7-4d21-bd84-6477cb3a0686.tif, this=0x7f2eb418b860)
END RequestId: 95949854-f0ec-43e7-b38a-3346139b6777
REPORT RequestId: 95949854-f0ec-43e7-b38a-3346139b6777	Duration: 330.59 ms	Billed Duration: 331 ms	Memory Size: 3008 MB	Max Memory Used: 225 MB	

Details on GoogleMapsCompatible:
https://gdal.org/drivers/raster/cog.html
TILING_SCHEME=CUSTOM/GoogleMapsCompatible/other: Default value: CUSTOM. If set to a value different than CUSTOM, the definition of the specified tiling scheme will be used to reproject the dataset to its CRS, select the resolution corresponding to the closest zoom level and align on tile boundaries at this resolution.

Demo file at: http://static2.skysight.io/demo.tiff

Driver: GTiff/GeoTIFF
Files: none associated
Size is 32768, 25088
Coordinate System is:
PROJCRS["WGS 84 / Pseudo-Mercator",
    BASEGEOGCRS["WGS 84",
        ENSEMBLE["World Geodetic System 1984 ensemble",
            MEMBER["World Geodetic System 1984 (Transit)"],
            MEMBER["World Geodetic System 1984 (G730)"],
            MEMBER["World Geodetic System 1984 (G873)"],
            MEMBER["World Geodetic System 1984 (G1150)"],
            MEMBER["World Geodetic System 1984 (G1674)"],
            MEMBER["World Geodetic System 1984 (G1762)"],
            MEMBER["World Geodetic System 1984 (G2139)"],
            ELLIPSOID["WGS 84",6378137,298.257223563,
                LENGTHUNIT["metre",1]],
            ENSEMBLEACCURACY[2.0]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4326]],
    CONVERSION["Popular Visualisation Pseudo-Mercator",
        METHOD["Popular Visualisation Pseudo Mercator",
            ID["EPSG",1024]],
        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["False easting",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["easting (X)",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["northing (Y)",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    USAGE[
        SCOPE["Web mapping and visualisation."],
        AREA["World between 85.06°S and 85.06°N."],
        BBOX[-85.06,-180,85.06,180]],
    ID["EPSG",3857]]
Data axis to CRS axis mapping: 1,2
Origin = (-20037508.342789243906736,15341217.324948014691472)
Pixel Size = (1222.992452562820063,-1222.992452562820290)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DATETIME=2022:02:10 01:00:20
Image Structure Metadata:
  COMPRESSION=YCbCr JPEG
  INTERLEAVE=PIXEL
  JPEGTABLESMODE=1
  JPEG_QUALITY=90
  LAYOUT=COG
  SOURCE_COLOR_SPACE=YCbCr
Tiling Scheme:
  NAME=GoogleMapsCompatible
  ZOOM_LEVEL=7
Corner Coordinates:
Upper Left  (-20037508.343,15341217.325) (180d 0' 0.00"W, 79d41'13.86"N)
Lower Left  (-20037508.343,-15341217.325) (180d 0' 0.00"W, 79d41'13.86"S)
Upper Right (20037508.343,15341217.325) (180d 0' 0.00"E, 79d41'13.86"N)
Lower Right (20037508.343,-15341217.325) (180d 0' 0.00"E, 79d41'13.86"S)
Center      (   0.0000000,  -0.0000000) (  0d 0' 0.01"E,  0d 0' 0.00"S)
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
  Overviews: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196
  Mask Flags: PER_DATASET 
  Overviews of mask band: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
  Overviews: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196
  Mask Flags: PER_DATASET 
  Overviews of mask band: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
  Overviews: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196
  Mask Flags: PER_DATASET 
  Overviews of mask band: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196
@Plantain Plantain added the bug Something isn't working label Feb 11, 2022
@Plantain Plantain changed the title Imagery is always reprojected, even if it is already the correct projection and tile aligned Imagery is always reprojected, even if it is already correctly projected and tile aligned Feb 11, 2022
@vincentsarago
Copy link
Member

@Plantain I'm not sure to really follow.

TiTiler uses rio-tiler which use rasterio WarpedVRT https://github.com/cogeotiff/rio-tiler/blob/master/rio_tiler/reader.py#L83 which is why you see GDALWarpKernel()::GWKRealCase() it doesn't means there is reprojection. if your COG is aligned with the TMS the tile image should be equal to internal block.

This is tested in https://github.com/cogeotiff/rio-cogeo/blob/master/tests/test_web.py#L135-L212. You can also debug this using https://github.com/developmentseed/tilebench

that's is said, if there is an issue this should be in rio-tiler

@geospatial-jeff
Copy link
Contributor

geospatial-jeff commented Feb 11, 2022

Does GDAL not align the COG properly

From my experience there may be small rounding errors that cause GDAL to slightly misalign each block in the image, requiring web-optimized readers to send multiple requests to fetch a single tile. This depends a lot on your input data and how much warping GDAL needs to perform to reproject to 3857. The fix I have used for this in the past is to "pre-align" your data by first creating a Warped VRT that is aligned to 3857 before creating your COG. This gives you a little bit more control over what GDAL is doing:

  • CRS is EPSG:3857
  • The tlx/tly of the geotransform matches that of an XYZ tile at the min zoom (smallest overview), the resolution of the geotransform matches the highest zoom level (source resolution).
  • Width and height should be equal to your decimation multiplied by the tile size - (2 ** (max_zoom - min_zoom)) * 256.

What immediately stands out to me is your spatial resolution - (1222.992452562820063,-1222.992452562820290) - is not the same for X and Y directions which can cause rounding errors especially on larger images. Also the tile size in the Y direction is a multiple of 196 when it really should be 256.

First ran into this writing https://github.com/geospatial-jeff/aiocogeo. Note that it has been a while since I've created COGs without pre-aligning the data first, so this may have been fixed. As @vincentsarago mentioned, I would highly recommend using https://github.com/developmentseed/tilebench to debug as it shows you alignment between COG blocks and XYZ tiles.

@Plantain
Copy link
Author

Thanks both for the context and ideas - I did suspect this probably wasn't a titiler issue but I wasn't sure where to start below it.

I'm not in control of that spatial resolution or the X/Y directions when using TILING_SCHEME=GoogleMapsCompatible - so I guess this is still an issue in GDAL (using 3.3.2, will try 3.4.1...)

I have tried to debug this with tilebench and I'm not sure if I am interpreting the results correctly - it looks like in most rows a tile fetch is 2 GET's, but every third row inexplicably is 3 GET's. If everything was aligned correctly it would be 1 GET or 2 for a tile?

tilebench viz http://static2.skysight.io/demo.tiff --config GDAL_INGESTED_BYTES_AT_OPEN=200000 --config GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR
ex

@vincentsarago
Copy link
Member

@Plantain for your file http://static2.skysight.io/demo.tiff only the raw resolution (level 0) is aligned with the mercator grid.
As for the 3 GET, this is due to the fact that GDAL and rio-tiler (morecantile) use a slightly different way to define the TileMatrixSet used to get the tile bounding box.

https://github.com/OSGeo/gdal/blob/35c07b18316b4b6d238f6d60b82c31e25662ad27/gcore/tilematrixset.cpp#L79-L108 vs https://github.com/developmentseed/morecantile/blob/master/morecantile/data/WebMercatorQuad.json

the differences in ☝️ is really small but Morecantile use the values provided by OGC 🤷‍♂️

can I ask which version of GDAL you used to create the COG? and also what was the command you used?

also @geospatial-jeff raises a valid point about the resolution being different in x and y 🤷

$ tilebench profile http://static2.skysight.io/demo.tiff --tile  7-70-58 --config GDAL_INGESTED_BYTES_AT_OPEN=200000 --config GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR | jq
{
    "LIST": {
        "count": 0
    },
    "HEAD": {
        "count": 1
    },
    "GET": {
        "count": 3,
        "bytes": 262144,
        "ranges": [
            "0-229375",
            "46661632-46678015",
            "47595520-47611903"
        ]
    },
    "Timing": 0.41567397117614746
}

# use rio cogeo COG
$ rio cogeo create demo.tiff demo_cog.tif -w -p jpeg --blocksize 256 --co JPEG_QUALITY=90
$ tilebench profile http://0.0.0.0:8000/demo_cog.tif --tile  7-70-58 --config GDAL_INGESTED_BYTES_AT_OPEN=200000 --config GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR | jq
{
  "LIST": {
    "count": 0
  },
  "HEAD": {
    "count": 1
  },
  "GET": {
    "count": 2,
    "bytes": 245760,
    "ranges": [
      "0-229375",
      "48955392-48971775"
    ]
  },
  "Timing": 0.13192009925842285
}

@Plantain
Copy link
Author

Plantain commented Feb 14, 2022 via email

@Plantain
Copy link
Author

Plantain commented Feb 14, 2022 via email

@vincentsarago
Copy link
Member

rasterio._err.CPLE_AppDefinedError: Reprojection failed, err = 2050,
further errors will be suppressed on the transform object.

I though this was fixed in rasterio 1.3a3 🤷 . but then there is another issue because the bounds rio-cogeo will get here https://github.com/cogeotiff/rio-cogeo/blob/master/rio_cogeo/utils.py#L93-L97 is wrong (I'll fix this)

GEOS projection is really hard to handle 😭

@Plantain
Copy link
Author

Plantain commented Feb 14, 2022 via email

@vincentsarago
Copy link
Member

As for the 3 GET, this is due to the fact that GDAL and rio-tiler (morecantile) use a slightly different way to define the TileMatrixSet used to get the tile bounding box.

This is in fact not true because we have a test in rio-tiler to make sure we aligned the bounds with the internal tile to avoid rounding issue https://github.com/cogeotiff/rio-tiler/blob/master/rio_tiler/utils.py#L265-L283

The more I look at this the more I think there is something going on with the Y resolution in GDAL.

@geospatial-jeff
Copy link
Contributor

geospatial-jeff commented Feb 15, 2022

This is in fact not true because we have a test in rio-tiler to make sure we aligned the bounds with the internal tile to avoid rounding issue https://github.com/cogeotiff/rio-tiler/blob/master/rio_tiler/utils.py#L265-L283

Yeah I remember we used to have problem with tile alignment when first building morecantile until we implemented this snapping logic.

I have tried to debug this with tilebench and I'm not sure if I am interpreting the results correctly - it looks like in most rows a tile fetch is 2 GET's, but every third row inexplicably is 3 GET's. If everything was aligned correctly it would be 1 GET or 2 for a tile?

This indicates to me that the issue is happening in the Y direction (not the X), and probably related to the slightly different Y resolution. Each row from the origin (top-left corner) will have a little bit of error because of the Y resolution, that error propagates to an extra tile read every third row.

A little extra error in the Y direction would cause 3 GET requests instead of 2. 1 for the header, 1 for the tile in question, and 1 for the tile's southern neighbor. If there was any error in the X direction we would see 5 GET requests, as we'd also be fetching the lower right and right neighbor. And the only thing different between X/Y in this case is resolution 🤷

@jratike80
Copy link

I believe the real reason it that you have not used the -co ALIGNED_LEVELS= creation option. Without that only the full resolution image is aligned, and your example requests are hitting the overview levels, which are not aligned.

Try to reach a result like here and try again

gdal_translate -of cog -co TILING_SCHEME=GoogleMapsCompatible -co ALIGNED_LEVELS=7 P4433H.tif P4433H_cog.tif
...
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
  Overviews: 16384x16384, 8192x8192, 4096x4096, 2048x2048, 1024x1024, 512x512, 256x256

@vincentsarago
Copy link
Member

@jratike80 we see anormal GET request even for the highest resolution (were we make sure we are not requesting the overviews)

@jratike80
Copy link

Pity, it would have been so easy fix. But your example was obviously not hitting the full resolution

[Fri Feb 11 06:39:40 2022].1789, 8.6002: GDAL: GDALWarpKernel()::GWKRealCase() Src=29181,15357,262x134 Dst=0,0,256x128
[Fri Feb 11 06:39:40 2022].2199, 8.6412: GDAL: GDALWarpKernel()::GWKRealCase() Src=29181,15485,262x134 Dst=0,128,256x128

@vincentsarago
Copy link
Member

@jratike80 can you explain why you believe this from the kernels?

@jratike80
Copy link

Sorry, just bad thinking I guess. But I would be interested in understanding what this means
Src=29181,15357,262x134 Dst=0,0,256x128
Is the 262x134 pixels from the source scaled into area 0,0,256x128, or is the input data cropped from the right and bottom?

@vincentsarago
Copy link
Member

GDAL WebOptimized COG

$ gdal_translate -of COG http://static2.skysight.io/himawari.tiff -co TILING_SCHEME=GoogleMapsCompatible -co COMPRESS=JPEG -co ZOOM_LEVEL_STRATEGY=UPPER 

$ gdalinfo himawari_cog.tif
Driver: GTiff/GeoTIFF
Files: himawari_cog.tif
Size is 32768, 25088
Coordinate System is:
...
Origin = (-20037508.342789243906736,15341217.324948014691472)
Pixel Size = (1222.992452562820063,-1222.992452562820290)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DATETIME=2022:02:05 00:00:20
Image Structure Metadata:
  COMPRESSION=YCbCr JPEG
  INTERLEAVE=PIXEL
  LAYOUT=COG
  SOURCE_COLOR_SPACE=YCbCr
Tiling Scheme:
  NAME=GoogleMapsCompatible
  ZOOM_LEVEL=7
Corner Coordinates:
Upper Left  (-20037508.343,15341217.325) (180d 0' 0.00"W, 79d41'13.86"N)
Lower Left  (-20037508.343,-15341217.325) (180d 0' 0.00"W, 79d41'13.86"S)
Upper Right (20037508.343,15341217.325) (180d 0' 0.00"E, 79d41'13.86"N)
Lower Right (20037508.343,-15341217.325) (180d 0' 0.00"E, 79d41'13.86"S)
Center      (   0.0000000,  -0.0000000) (  0d 0' 0.01"E,  0d 0' 0.00"S)
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
  NoData Value=0
  Overviews: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
  NoData Value=0
  Overviews: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
  NoData Value=0
  Overviews: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196

$ tilebench profile http://0.0.0.0:8000/himawari_cog.tif --tile  7-70-58 --config GDAL_INGESTED_BYTES_AT_OPEN=200000 --config GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR --add-kernels | jq
{
  "LIST": {
    "count": 0
  },
  "HEAD": {
    "count": 1
  },
  "GET": {
    "count": 3,
    "bytes": 262144,
    "ranges": [
      "0-229375",
      "28114944-28131327",
      "28688384-28704767"
    ]
  },
  "WarpKernels": [
    [
      "Src=17920,11008,256x129",
      "Dst=0,0,256x128"
    ],
    [
      "Src=17920,11136,256x129",
      "Dst=0,128,256x128"
    ]
  ],
  "Timing": 0.13547229766845703
}

Rio-cogeo Web-Optimized COG

$ rio cogeo create http://static2.skysight.io/himawari.tiff himawari_cogeo.tif -p jpeg -w --co JPEG_QUALITY=90 --zoom-level-strategy upper --blocksize 256

$ gdalinfo himawari_cog.tif  
Driver: GTiff/GeoTIFF
Files: himawari_cog.tif
Size is 32768, 25088
Coordinate System is:
...
Origin = (-20037508.342789243906736,15341217.324948014691472)
Pixel Size = (1222.992452562820063,-1222.992452562820290)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DATETIME=2022:02:05 00:00:20
Image Structure Metadata:
  COMPRESSION=YCbCr JPEG
  INTERLEAVE=PIXEL
  LAYOUT=COG
  SOURCE_COLOR_SPACE=YCbCr
Tiling Scheme:
  NAME=GoogleMapsCompatible
  ZOOM_LEVEL=7
Corner Coordinates:
Upper Left  (-20037508.343,15341217.325) (180d 0' 0.00"W, 79d41'13.86"N)
Lower Left  (-20037508.343,-15341217.325) (180d 0' 0.00"W, 79d41'13.86"S)
Upper Right (20037508.343,15341217.325) (180d 0' 0.00"E, 79d41'13.86"N)
Lower Right (20037508.343,-15341217.325) (180d 0' 0.00"E, 79d41'13.86"S)
Center      (   0.0000000,  -0.0000000) (  0d 0' 0.01"E,  0d 0' 0.00"S)
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
  NoData Value=0
  Overviews: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
  NoData Value=0
  Overviews: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
  NoData Value=0
  Overviews: 16384x12544, 8192x6272, 4096x3136, 2048x1568, 1024x784, 512x392, 256x196

$ tilebench profile http://0.0.0.0:8000/himawari_cogeo.tif --tile  7-70-58 --config GDAL_INGESTED_BYTES_AT_OPEN=200000 --config GDAL_DISABLE_READDIR_ON_OPEN=EMPTY_DIR --add-kernels | jq
{
  "LIST": {
    "count": 0
  },
  "HEAD": {
    "count": 1
  },
  "GET": {
    "count": 2,
    "bytes": 245760,
    "ranges": [
      "0-229375",
      "50561024-50577407"
    ]
  },
  "WarpKernels": [
    [
      "Src=17920,11008,256x128",
      "Dst=0,0,256x128"
    ],
    [
      "Src=17920,11136,256x128",
      "Dst=0,128,256x128"
    ]
  ],
  "Timing": 0.13330793380737305
}

☝️ I don't think the kernels tell we are reading the overview. the 129 value might tell that we are reading over the tile!

As Even, said the error is maybe on the reader side 🤷 but we first assumed it was because the non-square resolution

@developmentseed developmentseed locked and limited conversation to collaborators Feb 18, 2022
@vincentsarago vincentsarago converted this issue into discussion #435 Feb 18, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants