Hi Paul, thanks for the reply. I hadn’t thought to use grdcut to find the minimum domain.
However, I can’t get it to work! Using -J doesn’t seem to change the bounding box of the output grid if I specify -R, and if I don’t specify -R then I have to give either -Z or -S, or else I get an error.
kmbp:gmttest kylebradley$ gmt --version
6.1.1
kmbp:gmttest$ gmt grdcut @earth_relief_01d_p -Gglobaldem.nc -R-180/180/-90/90
kmbp:gmttest$ gmt grdinfo globaldem.nc
globaldem.nc: Title: Produced by grdcut
globaldem.nc: Command: grdcut @earth_relief_01d_p -Gglobaldem.nc -R-180/180/-90/90
globaldem.nc: Remark: Obtained by Gaussian Cartesian filtering (111.2 km fullwidth) from SRTM15+V2.1.nc [Tozer et al., 2019; http://dx.doi.org/10.1029/2019EA000658]
globaldem.nc: Pixel node registration used [Geographic grid]
globaldem.nc: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
globaldem.nc: x_min: -180 x_max: 180 x_inc: 1 name: longitude n_columns: 360
globaldem.nc: y_min: -90 y_max: 90 y_inc: 1 name: latitude n_rows: 180
globaldem.nc: z_min: -8182 z_max: 5651.5 name: elevation (m)
globaldem.nc: scale_factor: 1 add_offset: 0
globaldem.nc: format: netCDF-4 chunk_size: 180,180 shuffle: on deflation_level: 3
First, just clip the grid without -JS. I chose a domain larger than needed.
kmbp:gmttest$ gmt grdcut -R90/170/-40/40 globaldem.nc -Goutput1.nc
kmbp:gmttest$ gmt grdinfo output1.nc
output1.nc: Title: Produced by grdcut
output1.nc: Command: grdcut -R90/170/-40/40 globaldem.nc -Goutput1.nc
output1.nc: Remark: Obtained by Gaussian Cartesian filtering (111.2 km fullwidth) from SRTM15+V2.1.nc [Tozer et al., 2019; http://dx.doi.org/10.1029/2019EA000658]
output1.nc: Pixel node registration used [Geographic grid]
output1.nc: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
output1.nc: x_min: 90 x_max: 170 x_inc: 1 name: longitude n_columns: 80
output1.nc: y_min: -40 y_max: 40 y_inc: 1 name: latitude n_rows: 80
output1.nc: z_min: -8182 z_max: 5208.5 name: elevation (m)
output1.nc: scale_factor: 1 add_offset: 0
output1.nc: format: classic
Try using -JS:
kmbp:gmttest$ gmt grdcut -JS130/0/30 -R90/170/-40/40 globaldem.nc -Goutput2.nc
kmbp:gmttest$ gmt grdinfo output2.nc
output2.nc: Title: Produced by grdcut
output2.nc: Command: grdcut -JS130/0/30 -R90/170/-40/40 globaldem.nc -Goutput2.nc
output2.nc: Remark: Obtained by Gaussian Cartesian filtering (111.2 km fullwidth) from SRTM15+V2.1.nc [Tozer et al., 2019; http://dx.doi.org/10.1029/2019EA000658]
output2.nc: Pixel node registration used [Geographic grid]
output2.nc: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
output2.nc: x_min: 90 x_max: 170 x_inc: 1 name: longitude n_columns: 80
output2.nc: y_min: -40 y_max: 40 y_inc: 1 name: latitude n_rows: 80
output2.nc: z_min: -8182 z_max: 5208.5 name: elevation (m)
output2.nc: scale_factor: 1 add_offset: 0
output2.nc: format: classic
The only difference in the grids is the header text.
kmbp:gmttest$ ls -l output1.nc output2.nc
-rw-r–r-- 1 kylebradley staff 27864 Jul 6 07:18 output1.nc
-rw-r–r--@ 1 kylebradley staff 27876 Jul 6 07:19 output2.nc
Without -R I get this error:
kmbp:gmttest$ gmt grdcut -JS130/0/30 globaldem.nc -Goutput3.nc
grdcut [ERROR]: Must specify only one of the -R, -S or the -Z options
Trying -S with a 30 degree radius gets this:
kmbp:gmttest$ gmt grdcut -JS130/0/30 globaldem.nc -S30d -Goutput4.nc
grdcut [ERROR]: Distance units must be one of d|m|s|e|f|k|M|n|u