grdview - Create 3-D perspective image or surface mesh from a grid
grdview relief_file -Jparameters [ -B[p|s]parameters ] [ -C[cpt]] [ -Gdrapefile | -Ggrd_r,grd_g,grd_b ] [ -Iintensfile|intensity ] [ -Jz|Zparameters ] [ -K ] [ -Nlevel[+gfill] ] [ -O ] [ -P ] [ -Qargs[+m] ] [ -Rwest/east/south/north[/zmin/zmax][r] ] [ -Ssmooth ] [ -T[s][o[pen]] ] [ -U[just/dx/dy/][c|label] ] [ -Wtypepen ] [ -Xx_offset ] [ -Yy_offset ] [ -ccopies ] [ -n<flags> ] [ -p<flags> ] [ -t<transp> ]
Note: No space is allowed between the option flag and the associated arguments.
grdview reads a 2-D grid file and produces a 3-D perspective plot by drawing a mesh, painting a colored/grayshaded surface made up of polygons, or by scanline conversion of these polygons to a raster image. Options include draping a data set on top of a surface, plotting of contours on top of the surface, and apply artificial illumination based on intensities provided in a separate grid file.
Select one of following settings. For any of these choices, you may force a monochrome image by appending the modifier +m. Colors are then converted to shades of gray using the (monochrome television) YIQ transformation
For perspective view p, optionally append /zmin/zmax. (more ...) This option may be used to indicate the range used for the 3-D axes [Default is region given by the relief_file]. You may ask for a larger w/e/s/n region to have more room between the image and the axes. A smaller region than specified in the relief_file will result in a subset of the grid.
-Wtypepen
- -Wc
- Draw contour lines on top of surface or mesh (not image). Append pen attributes used for the contours. [Default: width = 0.75p, color = black, style = solid].
- -Wm
- Sets the pen attributes used for the mesh. [Default: width = 0.25p, color = black, style = solid]. You must also select -Qm or -Qsm for meshlines to be drawn.
- -Wf
- Sets the pen attributes used for the facade. [Default: width = 0.25p, color = black, style = solid]. You must also select -N for the facade outline to be drawn.
-X[a|c|f|r][x-shift[u]]
By default GMT writes out grid as single precision floats in a COARDS-complaint netCDF file format. However, GMT is able to produce grid files in many other commonly used grid file formats and also facilitates so called “packing” of grids, writing out floating point data as 1- or 2-byte integers. To specify the precision, scale and offset, the user should add the suffix =id[/scale/offset[/nan]], where id is a two-letter identifier of the grid type and precision, and scale and offset are optional scale factor and offset to be applied to all grid values, and nan is the value used to indicate missing data. In case the two characters id is not provided, as in =/scale than a id=nf is assumed. When reading grids, the format is generally automatically recognized. If not, the same suffix can be added to input grid file names. See grdconvert and Section Grid file format specifications of the GMT Technical Reference and Cookbook for more information.
When reading a netCDF file that contains multiple grids, GMT will read, by default, the first 2-dimensional grid that can find in that file. To coax GMT into reading another multi-dimensional variable in the grid file, append ?varname to the file name, where varname is the name of the variable. Note that you may need to escape the special meaning of ? in your shell program by putting a backslash in front of it, or by placing the filename and suffix between quotes or double quotes. The ?varname suffix can also be used for output grids to specify a variable name different from the default: “z”. See grdconvert and Sections Modifiers for COARDS-compliant netCDF files and Grid file format specifications of the GMT Technical Reference and Cookbook for more information, particularly on how to read splices of 3-, 4-, or 5-dimensional grids.
Except for Cartesian cases, we need to resample your geographic grid onto an equidistant projected grid. In doing so various algorithms come into play that projects data from one lattice to another while avoiding anti-aliasing, leading to possible distortions. One expected effect of resampling with splines is the tendency for the new resampled grid to slightly exceed the global min/max limits of the original grid. If this is coupled with tight CPT file limits you may find that some map areas may show up with fore- or background color due to the resampling. In that case you have two options: (1) Modify your CPT file to fit the resampled extrema (reported with -V) or (2) Impose clipping of resampled values so they do not exceed the input min/max values (add +c to your -n option).
To make a mesh plot from the file hawaii_grav.nc and drawing the contours given in the CPT file hawaii.cpt on a Lambert map at 1.5 cm/degree along the standard parallels 18 and 24, with vertical scale 20 mgal/cm, and looking at the surface from SW at 30 degree elevation, run
gmt grdview hawaii_grav.nc -Jl18/24/1.5c -Chawaii.cpt \ -Jz0.05c -Qm -N-100 -p225/30 -Wc > hawaii_grav_image.ps
To create a illuminated color perspective plot of the gridded data set image.nc, using the CPT file color.rgb, with linear scaling at 10 cm/x-unit and tickmarks every 5 units, with intensities provided by the file intens.nc, and looking from the SE, use
gmt grdview image.nc -Jx10.0c -Ccolor.rgb -Qs -p135/30 -Iintens.nc > image3D.ps
To make the same plot using the rastering option with dpi = 50, use
gmt grdview image.nc -Jx10.0c -Ccolor.rgb -Qi50 -p135/30 -Iintens.nc > image3D.ps
To create a color PostScript perspective plot of the gridded data set magnetics.nc, using the CPT file mag_intens.cpt, draped over the relief given by the file topography.nc, with Mercator map width of 6 inch and tickmarks every 1 degree, with intensities provided by the file topo_intens.nc, and looking from the SE, run
gmt grdview topography.nc -JM6i -Gmagnetics.nc -Cmag_intens.cpt \ -Qs -p140/30 -Itopo_intens.nc > draped3D.ps
Given topo.nc and the Landsat image veggies.ras, first run grd2rgb to get the red, green, and blue grids, and then drape this image over the topography and shade the result for good measure. The commands are
gmt grd2rgb veggies.ras -Glayer_%c.nc gmt grdview topo.nc -JM6i -Qi -p140/30 -Itopo_intens.nc \ -Glayer_r.nc,layer_g.nc,layer_b.nc > image.ps
For the -Qs option: PostScript provides no way of smoothly varying colors within a polygon, so colors can only vary from polygon to polygon. To obtain smooth images this way you may resample the grid file(s) using grdsample or use a finer grid size when running gridding programs like surface or nearneighbor. Unfortunately, this produces huge PostScript files. The alternative is to use the -Qi option, which computes bilinear or bicubic continuous color variations within polygons by using scanline conversion to image the polygons.