[gdal-dev] How to read tiles size of a tiff

Laurențiu Nicola lnicola at dend.ro
Wed May 17 00:23:17 PDT 2023


Hi Andy,

gdalinfo is the tool that displays information about rasters. Yours is 337x217 pixels, with a 337x24 block size, which is completely unrelated to the OL tiling grid, and there's no -256 here.

The only unusual thing about your image is that instead of the customary positive X, negative Y cell spacing, it has (-70, 70) meters. This can sometimes cause problems, even for GDAL. OL might be assuming negative Y spacing, ending up with a negative size later.

I think you can fix it by flipping the image pixels in both directions, then updating the geotransform.

Regards,
Laurentiu

On Wed, May 17, 2023, at 09:27, andy wrote:
> Hi,
> I've been having trouble using a tiff on openlayers, and I've found that it depends on it having a negative tile height (-256).
> This is the tiff: https://andy-aws.s3.eu-north-1.amazonaws.com/sample_dnw_byte.tiff
> 
> I'm able to read tiles size in OL, using this
> 
>   source.getView().then(() => {
>     console.log(source.getTileGrid());
>   });
> 
> Is there some gdal CLI to read tiles size?
> Using gdalinfo it seems to me that I do not have it.
> 
> Thank you
> 
> --
> ___________________
> 
> Andrea Borruso
> website: https://medium.com/tantotanto
> 38° 7' 48" N, 13° 21' 9" E, EPSG:4326
> ___________________
> 
> "cercare e saper riconoscere chi e cosa,
>  in mezzo all’inferno, non è inferno, 
> e farlo durare, e dargli spazio"
> 
> Italo Calvino
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230517/5646b40a/attachment.htm>


More information about the gdal-dev mailing list