[gdal-dev] Question on converting netCDF to GTiff
Even Rouault
even.rouault at spatialys.com
Wed Oct 23 10:54:16 PDT 2019
On mercredi 23 octobre 2019 13:41:45 CEST Stephen Woodbridge wrote:
> Hi,
>
> I have a netCDF grid of Float32 values that I want to convert to GTiff
> with Int16 values. The min/max values will support this without scaling,
> but I'm not sure what will happen to the NODATA value =
> 9.96920996838686905e+36.
>
> Ideally, I would like to set it to something like 32000 but not sure how
> to do that.
>
> I've gotten as far as:
>
> gdal_translate -of GTiff -co TILED=YES -ot Int16 -a_srs EPSG:4326
> GEBCO_2019.nc gebco_2019.tif
>
> Which runs and looks ok except NODATA is set the same and that value
> clearly will not fit in an Int16. Now it is possible that the grid
> doesn't actually have any nodata cells set and only has the value
> defined but I'm not sure how to check if that is the case.
To check if there are cells set to NODATA, with recent enough GDAL (3.0 I
think), with gdalinfo -stats, you'll see a STATISTICS_VALID_PERCENT item. If
it is not 100, then there are nodata cells.
To do nodata value remapping, use gdalwarp -srcnodata XX -dstnodata YY
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list