[gdal-dev] WG: Wrong results during translate input.tif file to output.xyz file with gdal_translate.exe

Rahkonen Jukka jukka.rahkonen at maanmittauslaitos.fi
Mon Jun 2 02:36:32 PDT 2025


Hi,

Supplementing my previous answer:
If you do not like seeing z values -3.402823e+38 in the output xyz file, you can change them into your favorite value by using gdalwarp instead of gdal_translate. For example if you'd prefer 0 as nodata, run

gdalwarp -of XYZ -dstnodata 0 input.tif output.xyz

Corresponding documentation https://gdal.org/en/stable/programs/gdalwarp.html#cmdoption-gdalwarp-dstnodata

I guess that the following part may be difficult to understand if you are not yet so experienced with the concept of nodata

"New files will be initialized to this value and if possible the nodata value will be recorded in the output file. Use a value of None to ensure that nodata is not defined."

With nodata there are things to do:
-If the pixel does not carry any real information, store some predefined value for the pixel to tell that there is nothing interesting there.
- If the file format allows, store the nodata value into metadata "In this file, value [ ] means nodata and corresponding pixels do not carry any information".

In the sentense "New files will be initialized to this value" mean the first point, and "if possible the nodata value will be recorded in the output file" deals with the latter point, the metadata thing. You have already seen that GeoTIFF supports storing the nodata value into the metadata. The simple XYZ format does not support metadata and user must know by some other means what value stands for nodata.

-Jukka Rahkonen-

________________________________________
Lähettäjä: gdal-dev <gdal-dev-bounces at lists.osgeo.org> käyttäjän Rahkonen Jukka via gdal-dev <gdal-dev at lists.osgeo.org> puolesta
Lähetetty: Maanantai 2. kesäkuuta 2025 11.56
Vastaanottaja: Javier Jimenez Shaw <j1 at jimenezshaw.com>; gdal-dev at lists.osgeo.org <gdal-dev at lists.osgeo.org>; Marián Hadri <Marian.Hadri at rib-software.com>
Aihe: Re: [gdal-dev] WG: Wrong results during translate input.tif file to output.xyz file with gdal_translate.exe


Hi,

Run:
gdalinfo input.tif -stats

See among other information:
...
Band 1 Block=1905x1 Type=Float32, ColorInterp=Gray
  Minimum=643.147, Maximum=927.145, Mean=735.006, StdDev=69.669
  NoData Value=-3.402823e+38
  Metadata:
    STATISTICS_MINIMUM=643.14666748047
    STATISTICS_MAXIMUM=927.14501953125
    STATISTICS_MEAN=735.00611216951
    STATISTICS_STDDEV=69.669350319879
    STATISTICS_VALID_PERCENT=48.23

It means that 100-48.23=51.77 percent of the pixels are nodata, and nodata pixels have a value -3.402823e+38.

You must just tell in your next processing steps that your .xyz file contain also nodata values, just like the original data.

-Jukka Rahkonen-



________________________________________
Lähettäjä: gdal-dev <gdal-dev-bounces at lists.osgeo.org> käyttäjän Marián Hadri via gdal-dev <gdal-dev at lists.osgeo.org> puolesta
Lähetetty: Maanantai 2. kesäkuuta 2025 11.37
Vastaanottaja: Javier Jimenez Shaw <j1 at jimenezshaw.com>; gdal-dev at lists.osgeo.org <gdal-dev at lists.osgeo.org>
Aihe: [gdal-dev] WG: Wrong results during translate input.tif file to output.xyz file with gdal_translate.exe

Hallo, excuse me, this is the correct link ...https://d.rib-software.com/iTWO_civil/gdaltmp/input.tifBest regards, Marian HadriMarián Hadri  DeveloperE-Mail  Marian.Hadri at rib-software.comTelefon  +49(711)7873-339[X]RIB Software GmbH | Epplestraße 225, Haus 2, 70567 Stuttgart, GermanySitz Stuttgart. Amtsgericht Stuttgart HRB 783426. Geschäftsführer: René Wolf, Tobias Hamacher.
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev




More information about the gdal-dev mailing list