I’ve tried many variations on the syntax, but have not been able to get around this, though nothing appears wrong when looking at the nc file with grdinfo or gdalinfo.
It is known that those grids have a problem with the registration (see it here) maybe it can explain something. But note that this syntax -Rd178/-39.5/179.4/-38.8+r is invalid. -Rd is a global region. An a final thing is that you can access the .asc file directly. No need to convert before cut.
It seems I naively assumed the esri header info would allow GMT to translate the xy grid data to lat lon for me. The NIWA website says the xy grid data use EPSG 3994. Perhaps I need to use the EPSG code in my GMT commands? I see there was a correction to the GDAL libraries four years ago to make these data read correctly.
GMT can read those esri files natively. No need to convert or do anything else. But, as I said and linked, those files have a wrong header info regarding the grid registration.
I think the data in the files you linked are different in that they appear to be natively in lat lon, while my file is just in grid xy offsets on pixel centers with 250 m pixels. I have not figured out how to reference the xy grid to translate it to lat lon it seems.
grd2xyz produces x_coord, y_coord, z where x|y_coord are coordinates in the grid’s coordinate system. Are you saying that they are not geographical coordinates and you want them? Then use mapproject or grdproject the esri grid.
My ultimate goal is to extract bathymetric profiles for acoustic propagation models. I tried:
gmt grdproject nzbathymetry_2016_ascii-grid.asc -GNZLL.nc -Jm100 -I -C
which produces a lat lon grid, but it is nowhere near New Zealand. I used 100 as 100 E is listed as the longitude of the central meridian while -41 is listed as the latitude of truescale.
OK, -Jm100 is not good for sure. Lower case are for map scales. Are you sure the asc grid is in Mercator projection? Because to inverse project you must know the data projection … but I remember you mentioned an EPSG, try
The arcgis site suggests the bounds should be
West longitude: 161.15
East longitude: 179.695
North latitude: -31.329
South latitude: -49.249
but
gmt grdinfo nzbat_geo.nc
grdinfo [WARNING]: Guessing of registration in conflict between x and y, using gridline
nzbat_geo.nc: Title: GDAL Band Number 1
nzbat_geo.nc: Command: Wed Jul 08 06:15:41 2020: GDAL Create(nzbat_geo.nc, … )
nzbat_geo.nc: Remark:
nzbat_geo.nc: Gridline node registration used [Geographic grid]
nzbat_geo.nc: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
nzbat_geo.nc: x_min: 157.001255882 x_max: 193.00091029 x_inc: 0.00251061122869 name: longitude n_columns: 14340
nzbat_geo.nc: y_min: -57.4997149565 y_max: -24.0006293321 y_inc: 0.00251061122869 name: latitude n_rows: 13344
nzbat_geo.nc: z_min: 0 z_max: 0 name: GDAL Band Number 1
nzbat_geo.nc: scale_factor: 1 add_offset: 0
nzbat_geo.nc: format: classic