ArcGIS has unique advantages in spatial analysis of Geographic Information System, so it has become one of the main research tools for my current program. However, in the process of communication, due to the different choices in the data processing and displaying tools, we often encounter the problem of data format conversion. This post shows you how to use the GMT 4 command to convert the Arc ASCII data format to a netCDF recognized by GMT.
Arc ASCII to GMT netCDF
My post on the open databases of Geosciences listed some useful databases. In the figure below, we first selected and downloaded multibeam bathymetry data MAR.asc in Arc ASCII format from GMRT.
Then use the xyz2grd command to convert Arc ASCII into GMT netCDF format:
xyz2grd MAR.asc -GMAR.grd -E -V
For ASCII files downloaded from databases such as JAMSTEC, I prefer using nearneighbor interpolation:
blockmean MAR.dat -R-45.6/-44.2/25.3/27 -I0.001 > MAR.xyz
nearneighbor MAR.xyz -V -R -I -S0.002 -N2 -GMAR.grd
The output MAR.grd file is in GMT netCDF format.
GMT netCDF to Arc ASCII
When converting the data from GMT netCDF to Arc ASCII format, the netCDF file needs to be resampled firstly so that the resolution in the latitude and the longitude are exactly the same, and then converted to Arc ASCII format using the grd2xyz command:
grdsample MAR.grd -I0.001= -GMAR.nc
grd2xyz MAR.nc -E > MAR_G.asc
It is important to note here that the -I option in the resampling command should be appended with “=” to make sure the output MAR.nc file is sampled at exactly the same resolution in latitude and longitude, so that it can be used for the grd2xyz command to convert data formats.
The resulting MAR_G.asc file is in Arc ASCII format. Then calculate hillshade using ArcMAP, and you can see the multi-beam bathymetry of the Mid-Atlantic Ridge segment below:
Tips
The -E option is necessary when using the grd2xyz and xyz2grd commands to convert data involving Arc ASCII format.
When converting data from GMT netCDF to Arc ASCII format, keep the “=” in mind regarding the -I option of the resampling.
Note: all the codes in this post are of GMT 4 version, which might not work with later versions of GMT.