Open pcace opened 9 months ago
The problem comes probably from the interpretation of the pixel size and the orientation of the image. Have a look at the source data
gdalinfo dgm1_32_568_5941_1_hh.xyz
...
Origin = (567999.500000000000000,5940999.500000000000000)
Pixel Size = (1.000000000000000,1.000000000000000)
Corner Coordinates:
Upper Left ( 567999.500, 5940999.500)
Lower Left ( 567999.500, 5941999.500)
Upper Right ( 568999.500, 5940999.500)
Lower Right ( 568999.500, 5941999.500)
...
How to read this information:
That means that for showing the tiff image in EPSG:25832 the image must be flipped. See how the TIFF image looks with IrfanView that show the raw image, and in QGIS that knows to flip it.
Maybe gdal_merge.py cannot handle flipped images. Gdalbuildvrt cannot either
gdalbuildvrt merge.vrt *.tif
0...10...20...30.Warning 1: gdalbuildvrt does not support positive NS resolution. Skipping dgm1_32_568_5941_1_hh.tif
I did not make a proper test but I believe that you will have success by using gdalwarp that turns the image into north-up
gdalwarp -t_srs epsg:25832 dgm1_32_568_5941_1_hh.xyz dgm1_32_568_5941_1_hh.tif
I cannot say if there is a bug and where it actually could be, but I do believe that is it not easy for an average GDAL user to find out what happens. At least gdalbuildvrt gives a more meaningful error message.
Hi, thank you so much for your help! I think gdalwarp does the trick for me. The question is, if this is now a bug and should be fixed somehow, or can this be closed as this is kind of expected behaviour? Please close it here if you mean this is not a bug. i am not sure...
Thanks anyways for your extremely fast help!
As pointed out as well above by @jratike80 , -- 'the pixel size is 1,1 so each step to the right is increasing X and each step towards bottom is increasing Y'
You can also remedy the issue upstream in your gdal_translate or gdalwarp using the '-tr' parameter which defines pixel size -- as '1 -1' so that you have increasing x, decreasing y. e.g:
gdal_translate
${xyzFile} ${xyzFile}.tif -a_srs ${srs} -tr 1.0 -1.0`
Expected behavior and actual behavior.
i convert XYZ files to GeoTIFF:
gdal_translate ${xyzFile} ${xyzFile}.tif -a_srs ${srs}
and then merge them:gdal_merge.py -o merged.tif *.tif
the result is always:expected would be a proper merged geoTIFF. this only happens if i use the GeoTIFFS created by gdal_translate. using other GeoTIFFs the merge command works
Steps to reproduce the problem.
Here are the used XYZ Files. they are Projected in EPSG:25832. so we use: gdal_translate dgm1_32_568_5941_1_hh.xyz dgm1_32_568_5941_1_hh.xyz.tif -a_srs EPSG:25832`
dgm1_32_568_5941_1_hh.xyz.gz dgm1_32_570_5941_1_hh.xyz.gz dgm1_32_570_5942_1_hh.xyz.gz
and to merge
gdal_merge.py -o merged.tif *.tif
Operating system
POPOS22.04 & Debian 12
GDAL version and provenance
Version: GDAL 3.4.3, released 2022/04/22
GDALINFO
the gdalinfo on on resulting tiff file to merge looks like this: