0

I am trying to convert netCDF file from NASA Ocean Color website such as https://oceandata.sci.gsfc.nasa.gov/cgi/getfile/A2018001180000.L2_LAC_OC.nc now the file converts fine using the answer to Converting netCDF to geotiff file?.

Below is the code:

"gdal_translate"  -ot float32 -a_srs EPSG:4326  -co COMPRESS=deflate -of GTiff -a_nodata -32767.0 HDF5:"A2018001180000.L2_LAC_OC.nc"://geophysical_data/chlor_a A2018001180000.L2_LAC_OC.tif

However, the file created only displays in QGIS and it has the following limitations in QGIS and ArcGIS.

QGIS - The image displays fine but the minimum and maximum is wrong.

ArcGIS and Geoserver - the image is inverted and distorted.

Is there a way to have a geotiff file that works normally in all applications?

QGIS: enter image description here

ArcGIS: enter image description here

Geoserver: enter image description here

10
  • I'm guessing it's because you're changing the output datatype but not scaling the values at all. The answer you linked includes the "-unscale" argument
    – mikewatt
    Commented Jun 15, 2018 at 23:07
  • So do you mean -unscale will fix it?
    – wondim
    Commented Jun 16, 2018 at 1:15
  • I can't download your sample at the moment so I can't tell ya. Try it and see. I'm almost certain that you're truncating input data values by changing the output type without changing the underlying values themselves
    – mikewatt
    Commented Jun 18, 2018 at 16:11
  • Is there section of the above code that is truncating the values? The values are supposed to stay as they are though.
    – wondim
    Commented Jun 18, 2018 at 20:11
  • @gberard were you able to check the script?
    – wondim
    Commented Jun 25, 2018 at 15:42

1 Answer 1

0

The gdal code below is creating a georeferenced and valid Geotiff file. A vrt file needs to be created using gdal_translate first. Then that file needs to be converted to geotiff using gdalwarp.

gdal_translate -r cubic -of VRT -co COMPRESS=deflate -unscale -a_nodata -32767.0 -a_srs EPSG:4326  HDF5:"A2018001180000.L2_LAC_OC.nc"://geophysical_data/chlor_a  A2018001180000.L2_LAC_OC.vrt

gdalwarp -of GTIFF -tps  A2018001180000.L2_LAC_OC.vrt  A2018001180000.L2_LAC_OC.tif

This is how it looks now in geoserver with style.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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