Skip to content
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

Build GDAL with internal libtiff to better support COGs #1087

Closed
palmerj opened this issue Apr 6, 2019 · 10 comments
Closed

Build GDAL with internal libtiff to better support COGs #1087

palmerj opened this issue Apr 6, 2019 · 10 comments

Comments

@palmerj
Copy link
Contributor

palmerj commented Apr 6, 2019

Can we please build GDAL with internal Libtiff support?

This will help any QGIS user adding COG raster data from cloud sources (such as AWS S3) or any GDAL scripts querying large COGs.

Background

Currently when using GDAL or projects that depend on GDAL such, reading large Cloud Optimised Geotiffs (COGs) is very slow for random access to pixel data. In some cases large COGs can have many 10s if not 100s of MBs of header data (mostly IFD array data) and If GDAL it is built with external libtiff then the whole Geotiff header needs to be downloaded before pixel data can be fetched. If GDAL is built using internal libtiff the arrays that make up most of the IFD header are not automatically downloaded - only the parts needed to specify a pixel request, which are usually a very small amount of the overall header.

Describe the solution you'd like

Change the GDAL configure script to use --with-libtiff=internal. See PR: #1088

Describe alternatives you've considered

The libtiff project could be changed to support special compilation option, but this would require changing the existing public API of the library and would be a much harder task and would require some discussion with other libtiff stakeholders to see if this is possible. Even then this would take some time to flow through to an official release.

Additional context

The source code of the internal copy of libtiff in GDAL is actually identical
to libtiff upstream. But the internal copy is compiled with a special option
to do lazy loading of the arrays to support partially downloading the COG header.

@palmerj
Copy link
Contributor Author

palmerj commented Apr 6, 2019

See PR: #1088

@fjperini
Copy link
Collaborator

fjperini commented Apr 6, 2019

@palmerj Thanks for detailing everything.
I will apply this changes with other required ones.

@palmerj
Copy link
Contributor Author

palmerj commented Apr 6, 2019

Thank you @fjperini

@fjperini
Copy link
Collaborator

fjperini commented Apr 9, 2019

@palmerj I will apply this change. we can close this issue
thanks for the contribution!

@fjperini fjperini closed this as completed Apr 9, 2019
@Firefishy
Copy link

Firefishy commented Jul 3, 2020

FYI: Debian and Ubuntu packages use external libtiff. :-(

@pabs3
Copy link

pabs3 commented Jul 14, 2020

Anyone know how exactly the internal build of libtiff differs from the external build of libtiff?

@palmerj
Copy link
Contributor Author

palmerj commented Jul 15, 2020

Older versions of official libtiff APIs didn't allow for optimised reading of the tiff header (strile offset/count values from the [Strip|Tile][Offsets/ByteCounts] array.) The TIFFReadFromUserBuffer interface was added in 4.1 so that the user can directly provide the input buffer to decompress, and hence optimise the reading of the COG header. The GDAL internal version of libtiff also has this optimisation.

@pabs3
Copy link

pabs3 commented Jul 15, 2020 via email

@palmerj
Copy link
Contributor Author

palmerj commented Jul 15, 2020

But it's a new API in v4.1 (I think)

@pabs3
Copy link

pabs3 commented Jul 15, 2020 via email

evetion added a commit to evetion/Yggdrasil that referenced this issue Mar 3, 2022
So newer features work out of the box, such as `LERC` in `COG`. See https://gdal.org/drivers/raster/cog.html and similar PR at OSGeo/homebrew-osgeo4mac#1087
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants