OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.86k stars 2.53k forks source link

No NODATA in TIF created from VRT that references HDF datasets #1835

Closed kannes closed 5 years ago

kannes commented 5 years ago

Expected behavior and actual behavior.

I am trying to copy over or assign a NODATA value for a TIF created from a VRT referencing datasets in a HDF file. I am unable to get a TIF with a NODATA value.

I wonder if https://github.com/OSGeo/gdal/issues/1451 is related.

Steps to reproduce the problem.

Download and extract http://0x0.st/zJ7Q.zip (gone in 4 weeks!)

The included HDF file has three important datasets: latitude and longitude for point coordinates of sensings and the nitrogendioxide_tropospheric_column (among others) for the actual values.

$ gdalinfo HDF5:S5P_NRTI_L2__NO2____20190903T112303_20190903T112803_09790_01_010302_20190903T121309.hdf://PRODUCT/nitrogendioxide_tropospheric_column shows NoData Value=9.96920996838686905e+36.

There are three VRT files, following the approach of making a proper raster data set in https://lists.osgeo.org/pipermail/gdal-dev/2012-June/033147.html and https://gis.stackexchange.com/a/154360/51035

I did not manage to copy or assign a NODATA value to the resulting dataset.

I tried gdalwarp -geoloc -t_srs EPSG:4326 -srcnodata 9.96920996838686905e+36 nitrogendioxide_tropospheric_column.vrt srcnodata.tif and gdalwarp -geoloc -t_srs EPSG:4326 -dstnodata 9.96920996838686905e+36 nitrogendioxide_tropospheric_column.vrt dstnodata.tif

I tried adding <NoDataValue>9.96920996838686905e+36</NoDataValue> into the VRTRasterBand element of nitrogendioxide_tropospheric_column.vrt, then gdalwarp -geoloc -t_srs EPSG:4326 nitrogendioxide_tropospheric_column.vrt dstnodata.tif as well as with the srcnodata or dstnodata parameters as above. gdalinfo nitrogendioxide_tropospheric_column.vrt also did not show a NODATA value here.

The resulting TIFF never had a NODATA value, I checked with gdalinfo $file | grep -i nodata.

Operating system

Archlinux 64 bit

GDAL version and provenance

$ gdalinfo --version GDAL 3.0.0, released 2019/05/05

rouault commented 5 years ago

Works fine for me with GDAL 3.0and master branches

$ gdalwarp -geoloc -t_srs EPSG:4326 -dstnodata 9.96920996838686905e+36 nitrogendioxide_tropospheric_column.vrt dstnodata.tif -overwrite (you might also want to add -srcnodata 9.96920996838686905e+36 )
$ gdalinfo dstnodata.tif  | grep NoData
  NoData Value=9.96920996838686905e+36
kannes commented 5 years ago

Gah, I think I have been fooled by something. I can confirm that also works for me. Maybe a stray aux.xml file from a previous attempt with the same filename interfered? If that sounds reasonable, please excuse me for the issue and close it.