Objective: generate mercator tiles 256x256 from a huge jpeg2000 image.
Tool used: gdal2tiles.py
GDAL version: 3.2.2
Command line: gdal2tiles.py -z 19 -r [any] image.jp2 tiles/
Source image: image.jp2 is in CRS Lambert93 (2154), coming from IGN ORTHO-HR open database (resolution 20 cm per pixel) https://geoservices.ign.fr/documentation/diffusion/telechargement-donnees-libres.html#ortho-irc50cm-et-hr
Problem: there are some cracks in all tiles generated, visible on road or building edges (as shown in illustration). The artefact doesn't depend on the resampling method used.
Illustration: enter image description here

The samples are 256x256 pixels tiles, generated with gdal2tiles, with different -r options. 1_original.png is an extract (done with QGIS) from jp2 original image, for the same area than the tile.
The source CRS is well defined in source image metadata, so I don't use -s option on command line to specify it (I tried, but it doesn't change anything as expected).

  • 1
    Maybe the change of CRS (Lamber93 to 3857) introduces some distortions... – JGH Mar 16 at 19:11
  • Is there a way to avoid these distorsions? – kleio12345 Mar 16 at 19:12
  • Some interpolation methods are better/worst than others. (sorry, I can't give you a definitive solution) – JGH Mar 16 at 19:17
  • If you mean -r option of gdal2tiles, I tried all of them without any influence on the artefact (as it can be seen in the illustration) – kleio12345 Mar 16 at 19:28
  • 1
    Try gdalwarp -of VRT -t_srs epsg:3857 image.jp2 image.vrt and run gdal2tiles on that vrt file. Probably there is no difference. What JPEG2000 driver do you use? – user30184 Mar 16 at 20:06

Thanks to user30184, I got better results using gdalwarp before gdal2tiles:

Step 1:

gdalwarp -of VRT -s_srs EPSG:2154 -t_srs EPSG:3857 -r average -srcnodata "255 255 255" -dstnodata "255 255 255" image.jp2 image.vrt

Step 2:

gdal2tiles.py -z 19 -r average image.vrt ./tiles

New result obtained for the sample tile:
enter image description here

Remaining question: is there a need to use a second time -r average in gdal2tiles command, as resampling should have been done by gdalwarp?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.