[gdal-dev] TIF + TFW to GeoTIFF without decompression/recompression
Rahkonen Jukka (MML)
jukka.rahkonen at maanmittauslaitos.fi
Mon Sep 20 04:20:36 PDT 2021
Sorry for not reading your mail till the end after the signature.
I was wondering now if gdal_merge.py with the -createonly option could be useful for a user like me who can't program can use workarounds. However, for some reason the final step with geotifcp fails.
I first checked that combining baseline.tif and baseline.tfw succeeds and it did.
geotifcp -e baseline.tfw baseline.tif baseline_plus_geo.tif
Creating an empty geotif with gdal_merge is fast
gdal_merge -o mergetest.tif -createonly geotiff.tif
Copying GeoTIFF tags with the -g option fails always. I tried also non-empty GeoTIFFs as the source for the metadata.
geotifcp -g mergetest.tif baseline.tif baseline_plus_merge.tif
geo_print.c DefaultRead failed to read anything.
Failure in GTIFImport
Lähettäjä: Rahkonen Jukka (MML)
Lähetetty: maanantai 20. syyskuuta 2021 12.24
Vastaanottaja: 'Andrea Giudiceandrea' <andreaerdna at libero.it>
Kopio: 'gdal-dev at lists.osgeo.org' <gdal-dev at lists.osgeo.org>
Aihe: Re: [gdal-dev] TIF + TFW to GeoTIFF without decompression/recompression
Have you considered to use https://gdal.org/programs/gdal_edit.html?
Lähettäjä: gdal-dev <gdal-dev-bounces at lists.osgeo.org> Puolesta Andrea Giudiceandrea via gdal-dev
Lähetetty: maanantai 20. syyskuuta 2021 12.11
Vastaanottaja: gdal-dev at lists.osgeo.org
Aihe: [gdal-dev] TIF + TFW to GeoTIFF without decompression/recompression
gdal_transalte has an "hidden" feature (not mentioned in the docs ), introduced since GDAL 1.10 , which allows to convert .JPG + .JPW raster layer to GeoTIFF without decompressing and recompressing the raster image (a so called "lossless conversion of JPEG into JPEG-in-TIFF" ).
It seem to me the same is not possible if the source is a .TIF (e.g. a
JPEG-in-TIFF) + .TFW raster layer. In this case the image is always decompressed and then recompressed if a compression method is specified, thus adding another unnecessary lossy step.
I think the decompression / recompression cycle should obviously not be needed converting a TIFF file to a GeoTIFF file (unless image manipulation options are specified) and gdal_transalte should just copy the source TIF file and add the proper GeoTIFF metadata tags taken from the TFW file and from the -a_srs parameter.
Maybe is there any other "hidden" feature I haven't been able to find yet?
I know gdal_edit could also be used, but it cannot automatically take the georeferencing parameters from the TFW file.
It could also be possible to use the geotifcp cli tool from libgeotiff, but it seems it (the one shipped by OSGeo4W) has some issues handling JPEG-in-TIFF files (while it works well with other compression formats):
the "Warning, fractional scanline discarded." and "JPEGLib: Application transferred too few scanlines." errors are reported unsuccessfully trying to convert a JPEG-in-TIFF + TFW to a GeoTIFF.
Instead, the very old and almost nowhere to be found GeoTiffExamin gui tool can just add the proper GeoTIFF metadata tags, taken from the TFW file, to a TIFF file without modifying the raster image. Anyway the gui tool cannot be used for batch conversion.
gdal-dev mailing list
gdal-dev at lists.osgeo.org
More information about the gdal-dev