grdcut¶
Extract subregion from a grid
Synopsis¶
gmt grdcut ingrid -Goutgrid -Rregion [ -Fpolygonfile[+c][+i] ] [ -Jparameters ] [ -N[nodata] ] [ -Slon/lat/radius[+n] ] [ -V[level] ] [ -Z[min/max][+n|N|r] ] [ -fflags ] [ --PAR=value ]
Note: No space is allowed between the option flag and the associated arguments.
Description¶
grdcut will produce a new outgrid file which is a subregion of ingrid. The subregion is specified with -R as in other programs; the specified range must not exceed the range of ingrid (but see -N). If in doubt, run grdinfo to check range. Alternatively, define the subregion indirectly via a range check on the node values or via distances from a given point. Finally, you can use -J for oblique projections to determine the corresponding rectangular -R setting that will give a grid that fully covers the oblique domain. Complementary to grdcut there is grdpaste, which will join together two grid files along a common edge.
Required Arguments¶
- ingrid
This is the input grid file (see Grid File Formats).
- -Goutgrid
This is the output grid file.
Optional Arguments¶
- -Fpolygonfile[+c][+i]
Specify a multisegment closed polygon file. All grid nodes outside the polygon will be set to NaN. Append +i to invert that and set all nodes inside the polygon to NaN instead. Optionally, append +c to crop the grid region to reflect the bounding box of the polygon.
- -Jparameters
Specify the projection. (See full description) (See cookbook summary) (See projections table).
- -N[nodata]
Allow grid to be extended if new -R exceeds existing boundaries. Append nodata value to initialize nodes outside current region [Default is NaN].
- -Rxmin/xmax/ymin/ymax[+r][+uunit]
Specify the region of interest. This defines the subregion to be cut out. (See full description) (See cookbook information).
- -Slon/lat/radius[+n]
Specify an origin and radius; append a distance unit (see Units) and we determine the corresponding rectangular region so that all grid nodes on or inside the circle are contained in the subset. If +n is appended we set all nodes outside the circle to NaN.
- -V[level]
Select verbosity level [w]. (See full description) (See cookbook information).
- -Z[min/max][+n|N|r]
Determine a new rectangular region so that all nodes outside this region are also outside the given z-range [-inf/+inf]. To indicate no limit on min or max only, specify a hyphen (-). Normally, any NaNs encountered are simply skipped and not considered in the range-decision. Append +n to consider a NaN to be outside the given z-range. This means the new subset will be NaN-free. Alternatively, append +r to consider NaNs to be within the data range. In this case we stop shrinking the boundaries once a NaN is found [Default simply skips NaNs when making the range decision]. Finally, if your core subset grid is surrounded by rows and/or columns that are all NaNs, append +N to strip off such columns before (optionally) considering the range of the core subset for further reduction of the area.
- -f[i|o]colinfo (more …)
Specify data types of input and/or output columns.
- -^ or just -
Print a short message about the syntax of the command, then exit (NOTE: on Windows just use -).
- -+ or just +
Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exit.
- -? or no arguments
Print a complete usage (help) message, including the explanation of all options, then exit.
- --PAR=value
Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.
Units¶
For map distance unit, append unit d for arc degree, m for arc minute, and s for arc second, or e for meter [Default], f for foot, k for km, M for statute mile, n for nautical mile, and u for US survey foot. By default we compute such distances using a spherical approximation with great circles (-jg) using the authalic radius (see PROJ_MEAN_RADIUS). You can use -jf to perform “Flat Earth” calculations (quicker but less accurate) or -je to perform exact geodesic calculations (slower but more accurate; see PROJ_GEODESIC for method used).
Geographical And Time Coordinates¶
When the output grid type is netCDF, the coordinates will be labeled “longitude”, “latitude”, or “time” based on the attributes of the input data or grid (if any) or on the -f or -R options. For example, both -f0x -f1t and -R90w/90e/0t/3t will result in a longitude/time grid. When the x, y, or z coordinate is time, it will be stored in the grid as relative time since epoch as specified by TIME_UNIT and TIME_EPOCH in the gmt.conf file or on the command line. In addition, the unit attribute of the time variable will indicate both this unit and epoch.
Examples¶
Note: Below are some examples of valid syntax for this module.
The examples that use remote files (file names starting with @
)
can be cut and pasted into your terminal for testing.
Other commands requiring input files are just dummy examples of the types
of uses that are common but cannot be run verbatim as written.
To obtain data for an oblique Mercator projection map we need to extract more data that is actually used. This is necessary because the output of grdcut has edges defined by parallels and meridians, while the oblique map in general does not. Hence, to get all the data from the ETOPO2 data needed to make a contour map for the region defined by its lower left and upper right corners and the desired projection, use:
Suppose you have used surface to grid ship gravity in the region between 148E - 162E and 8N - 32N, and you do not trust the gridding near the edges, so you want to keep only the area between 150E - 160E and 10N - 30N, then:
To return the subregion of a grid such that any boundary strips where all values are entirely above 0 are excluded, try:
To return the subregion of a grid such that any boundary rows or columns that are all NaNs, try:
To return the subregion of a grid that contains all nodes within a distance of 500 km from the point 45,30 try:
To create a topography grid with data only inside France and set it to NaN outside France, based on the 10x10 minute DEM, try: