mmomtchev / node-gdal-async

Node.js bindings for GDAL (Geospatial Data Abstraction Library) with full async support
https://mmomtchev.github.io/node-gdal-async/
Apache License 2.0
133 stars 26 forks source link

Cannot open GeoTIFF with ZSDT compression #62

Closed JakobMiksch closed 1 year ago

JakobMiksch commented 1 year ago

When I open a GeoTIFF with ZSDT compression (see example file attached), I get the error: Cannot open TIFF file due to missing codec.

Opening the same file with gdalinfo or QGIS in the same environment works without problem.

It seems this error in the code is thrown: https://github.com/mmomtchev/node-gdal-async/blob/543a6e262463a4d34737054062109637f40e34fc/deps/libproj/proj/src/grids.cpp#L923-L928

Sample GeoTIFF: sample_zstd_error.tif.zip (GeoTIFF in a ZIP-file, because GitHub does not allow uploading tiff files directly)

My used versions:

GDAL 3.4.3, released 2022/04/22

gdal-async 3.5.3

Node 16.17.1

Is opening a ZSDT-compressed GeoTIFF a known limitation of gdal-async, is there any way to fix it?

mmomtchev commented 1 year ago

It is a limitation of the bundled GDAL.

gdal-async, when installed with its default options from npm, is a fully self-contained package which means that it must carry everything that it might use. This limits the number of external libraries that can be included - like zstd.

If you have a system-installed GDAL version that can read zstd and a working C++ environment you can use it instead of the bundled version:

npm install gdal-async --build-from-source --shared_gdal
JakobMiksch commented 1 year ago

Thanks @mmomtchev This way it worked. My current steps for installation are now:

I guess there is no way to directly install a system-linked gdal-async with npm install using just package.json, right ?

mmomtchev commented 1 year ago

Currently there is no support.

Whether it can be done at all is another question. GDAL has frequent ABI changes which are indicated by the version number of the library, GDAL 3.0 is 26, GDAL 3.1 is 27, GDAL 3.2 is 28 and, 3.6, the current one is 32. This means that binaries won't be compatible across these versions. Given that this addon uses the older Node.js API (NAN) which already requires one binary per Node.js version if we multiply this by one binary per GDAL minor version - on all platforms - I think that I would be over the Github opensource quota. So while not impossible, it would definitely be too much work to implement and maintain.