Opened 12 years ago

Last modified 9 years ago

#1599 new defect

netcdf input upside down raster

Reported by: michpaulatto Owned by: grass-dev@…
Priority: normal Milestone: 6.4.6
Component: Raster Version: 6.4.0
Keywords: input netcdf upside down raster Cc:
CPU: x86-64 Platform: Linux

Description

What I'm trying to do: I'm importing netcdf elevation and/or gravity grids (.grd) into grass.

The problem: imported raster is sometimes upside down

Example: two netcdf grid files generated with GMT's grdsample. dem.grd and grav.grd, see below output of grdinfo:

% grdinfo dem.grd

dem.grd: Title: dem.grd
dem.grd: Command: grdsample -R173/193/-39/-15 -I0.02 Complete_merged.grd -Gdem.grd
dem.grd: Remark:
dem.grd: Gridline node registration used
dem.grd: Grid file format: nf (# 18) GMT netCDF format (float) (COARDS-compliant) [DEFAULT]
dem.grd: x_min: 173 x_max: 193 x_inc: 0.02 name: longitude [degrees_east] nx: 1001
dem.grd: y_min: -39 y_max: -15 y_inc: 0.02 name: latitude [degrees_north] ny: 1201
dem.grd: z_min: -10804.1416016 z_max: 714.619628906 name: z
dem.grd: scale_factor: 1 add_offset: 0

% grdinfo grav.grd

grav.grd: Title: grav.grd
grav.grd: Command: grdsample -R173/193/-39/-15 -I0.1 temp -Ggrav.grd
grav.grd: Remark:
grav.grd: Gridline node registration used
grav.grd: Grid file format: nf (# 18) GMT netCDF format (float) (COARDS-compliant) [DEFAULT]
grav.grd: x_min: 173 x_max: 193 x_inc: 0.1 name: x nx: 201
grav.grd: y_min: -39 y_max: -15 y_inc: 0.1 name: y ny: 241
grav.grd: z_min: -270.356201172 z_max: 203.824752808 name: z
grav.grd: scale_factor: 1 add_offset: 0

When I import these two files into grass (from the GUI) dem.grd results in a correct raster while grav.grd results in an upside down raster. This happens with other grd files I've tried, but this example is quite interesting since the two grd files cover the same area, have the same dimensions and have been generated in exactly the same way. They have different grid spacing. Any clues?

Thanks. Michele.

Change History (3)

comment:1 by neteler, 12 years ago

Please report which GDAL version you use. There are a few issues in the related netCDF driver (more links therein to other tickets):

http://trac.osgeo.org/gdal/ticket/2846

http://trac.osgeo.org/gdal/ticket/1926

comment:2 by cmbarton, 12 years ago

I've been reading a number of highly variable NetCDF files in the last month while I'm here at NCAR, one of the big users of NetCDF.

I've found that some software reads NetCDF files upside down (including ImageJ, the current stable version of MultiSpec, and ArcGIS). We are speculating that this is because NetCDF raster files are meant to be read from the bottom left, rather than from the top left like normal image files--but like georeferenced raster maps.

However, r.in.gdal seems to consistently read these files correctly in all cases--once the proper input string has been determined. New dev versions of MultiSpec also are reading NetCDF files correctly now. (I added information to the GRASS Wiki for r.in.gdal to describe how to read *.nc files into GRASS.) These are working fine in GDAL 1.8 and 1.9

That said, the other tickets are from 3-4 years back and both refer to GMT files, as does this ticket. So I wonder if there is something that happens when GMT makes NetCDF or when they pass through GMT that throws GDAL off ?

Michael

comment:3 by martinl, 9 years ago

Milestone: 6.4.6
Note: See TracTickets for help on using tickets.