Opened 7 years ago

Closed 3 years ago

#5935 closed defect (wontfix)

GTiff to netcdf conversion fails

Reported by: aaschwanden Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: default Version: 1.11.2
Severity: normal Keywords: netcdf, conversion



I've come across a very strange behavior of the gdal netcdf driver when I try to remap a 500MB GTiff to new domain as a netCDF file. See bash script below.

When trying to directly convert the GTiff to a netcdf file of resolution $GRID, the resulting file has missing values on the whole left half of the domain as if only the right half was processed. This happens for both resolutions, 450m and 600m.

Now my first workaround was to first remap the file onto the new domain as a GTiff, then convert the GTiff to netcdf. The intermediate GTiff file looks correct for both resolutions. The resulting netcdf file is correct for 600m resolution, but, again, the right half is shown for 450m.

I've tried different creation options for the netcdf file (nc,nc2,nc4) and two gdal versions: GDAL 1.10.1, released 2013/08/26 and GDAL 1.11.2, released 2015/02/10. Always the same behavior. See attached png file.

I'm quite puzzled. Any ideas would be greatly appreciated.


gdal is a fantastic tool that I use on a daily basis, keep up the good work.


wget -nc${IBCAO}.tif

# Create a buffer that is a multiple of the grid resolution
# and works for grid resolutions up to 36km.
xmin=$((-638000 - $buffer_x))
ymin=$((-3349600 - $buffer_y))
xmax=$((864700 + $buffer_x))
ymax=$((-657600 + $buffer_y))

# choose netcdf type. Doesn't matter, behavior is the same for all nc/nc2/nc4/nc4c
CO='-co "FORMAT=NC"'

# First attempt, direct conversion from GTiff to netCDF
# This works for neither resolution
for GRID in 600 450; do
    rm -f g${GRID}m_ibcao.*
    gdalwarp $CO -overwrite -r average -t_srs EPSG:3413 -te $xmin $ymin $xmax $ymax -tr $GRID $GRID -of netCDF ${IBCAO}.tif  g${GRID}

# Second attempt, create an intermediate GTiff at desired resolution,
# then convert to netCDF.
# The intermediate GTiff file looks ok for both resolutions.
# This works for 600m but not for 450m
for GRID in 600 450; do
    rm -f g${GRID}m_ibcao-2s.*
    gdalwarp -overwrite -r average -t_srs EPSG:3413 -te $xmin $ymin $xmax $ymax -tr $GRID $GRID -of GTiff ${IBCAO}.tif  g${GRID}m_ibcao-2s.tif
    gdalwarp $CO -overwrite -of netCDF -s_srs EPSG:3413 -t_srs EPSG:3413 g${GRID}m_ibcao-2s.tif g${GRID}

Attachments (1)

g450m_ibcao.png (64.5 KB) - added by aaschwanden 7 years ago.
converted file. Only right side was processed?

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by aaschwanden

Attachment: g450m_ibcao.png added

converted file. Only right side was processed?

comment:1 Changed 3 years ago by Even Rouault

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub?. If you believe this ticket is still valid, you may file it to if it is not already reported there.

Note: See TracTickets for help on using tickets.