Bug #1086

grdsample does'nt respect -fg

Added by Michael 7 months ago. Updated 6 months ago.

Status:ClosedStart date:2017-05-01
Priority:NormalDue date:
Assignee:Paul% Done:

100%

Category:-
Target version:Candidate for next minor release
Affected version:5.3-svn Platform:

Description

I try to get subregion of ETOPO1 grid (https://www.ngdc.noaa.gov/mgg/global/relief/ETOPO1/data/bedrock/grid_registered/netcdf/ETOPO1_Bed_g_gmt4.grd.gz)

grdsample "ETOPO1_Bed_g_gmt4.grd" -G"bat.grd" -I0.1/0.1 -R179/196/49/61 -fg

but get error
grdsample: Error: Selected region exceeds the X-boundaries of the grid file by more than one x-increment!

grdinfo on this grid
ETOPO1_Bed_g_gmt4.grd: Title: ETOPO1_Bed_g_gmt4.grd
ETOPO1_Bed_g_gmt4.grd: Command:
ETOPO1_Bed_g_gmt4.grd: Remark:
ETOPO1_Bed_g_gmt4.grd: Gridline node registration used [Geographic grid]
ETOPO1_Bed_g_gmt4.grd: Grid file format: ni = GMT netCDF format (32-bit integer), COARDS, CF-1.5
ETOPO1_Bed_g_gmt4.grd: x_min: -180 x_max: 180 x_inc: 0.0166666666667 name: Longitude [degrees_east] n_columns: 21601
ETOPO1_Bed_g_gmt4.grd: y_min: -90 y_max: 90 y_inc: 0.0166666666667 name: Latitude [degrees_north] n_rows: 10801
ETOPO1_Bed_g_gmt4.grd: z_min: -10898 z_max: 8271 name: z
ETOPO1_Bed_g_gmt4.grd: scale_factor: 1 add_offset: 0
ETOPO1_Bed_g_gmt4.grd: format: classic

grdsample from GMT4 works perfect with this grid.

I get same result with GEBCO grids.

GMT5 r18101

History

#1 Updated by Joaquim 7 months ago

What are you expecting to happen here? That the program cuts the a chunk from the west side, adds it to east, resample and saves a grid with -R179/196/49/61? And you say that GMT4 does that?

#2 Updated by Michael 7 months ago

That the program cuts the a chunk from the west side, adds it to east, resample and saves a grid with -R179/196/49/61? And you say that GMT4 does that?

Exactly. This is a geographic grid with periodic boundary conditions. GMT4 takes this into account, GMT5 is not.

#3 Updated by Paul 7 months ago

  • Status changed from New to In Progress

I can confirm that the initial subset fails (grdcut has no problems). I will look into why. A workaround is to cut the subset with grdcut then do grdsample on that. I am sure you are aware that downsampling to 6m from a 1m grid will lead to aliasing. The way to do avoid that is to use grdfilter to obtain 6 m averages instead.

#4 Updated by Paul 7 months ago

  • Status changed from In Progress to Resolved
  • Assignee set to Paul
  • Target version set to Candidate for next minor release
  • % Done changed from 0 to 100

Should be fixed in r18118. I also added a new test script based on your failed command.

#5 Updated by Michael 7 months ago

Yes, it is fixed. Thank you!

#6 Updated by Joaquim 6 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF