Line reduction using the Douglas-Peucker algorithm
gmt simplify [ table ] -Ttolerance [ -V[level] ] [ -bbinary ] [ -dnodata ] [ -eregexp ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -qflags ] [ -:[i|o] ] [ --PAR=value ]
Note: No space is allowed between the option flag and the associated arguments.
simplify reads one or more data files and apply the Douglas-Peucker line simplification algorithm. The method recursively subdivides a polygon until a run of points can be replaced by a straight line segment, with no point in that run deviating from the straight line by more than the tolerance. Have a look at this site to get a visual insight on how the algorithm works (http://geometryalgorithms.com/Archive/algorithm_0205/algorithm_0205.htm)
Specifies the maximum mismatch tolerance in the user units. If the data are not Cartesian then append a suitable distance unit (see Units).
One or more ASCII (or binary, see -bi[ncols][type]) data table file(s) holding a number of data columns. If no tables are given then we read from standard input.
- -V[level] (more …)
Select verbosity level [w].
- -bi[ncols][t] (more …)
Select native binary format for primary input. [Default is 2 input columns].
- -bo[ncols][type] (more …)
Select native binary output. [Default is same as input].
- -d[i|o]nodata (more …)
Replace input columns that equal nodata with NaN and do the reverse on output.
- -e[~]“pattern” | -e[~]/regexp/[i] (more …)
Only accept data records that match the given pattern.
- -f[i|o]colinfo (more …)
Specify data types of input and/or output columns.
- -g[a]x|y|d|X|Y|D|[col]zgap[+n|p] (more …)
Determine data gaps and line breaks.
- -h[i|o][n][+c][+d][+msegheader][+rremark][+ttitle] (more …)
Skip or produce header record(s).
- -icols[+l][+sscale][+ooffset][,…][,t[word]] (more …)
Select input columns and transformations (0 is first column, t is trailing text, append word to read one word only).
- -ocols[,…][,t[word]] (more …)
Select output columns (0 is first column; t is trailing text, append word to write one word only).
- -q[i|o][~]rows[+ccol][+a|f|s] (more …)
Select input or output rows or data range(s) [all].
- -:[i|o] (more …)
Swap 1st and 2nd column on input and/or output.
- -^ 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.
Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.
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).
ASCII Format Precision¶
The ASCII output formats of numerical data are controlled by parameters in your gmt.conf file. Longitude and latitude are formatted according to FORMAT_GEO_OUT, absolute time is under the control of FORMAT_DATE_OUT and FORMAT_CLOCK_OUT, whereas general floating point values are formatted according to FORMAT_FLOAT_OUT. Be aware that the format in effect can lead to loss of precision in ASCII output, which can lead to various problems downstream. If you find the output is not written with enough precision, consider switching to binary output (-bo if available) or specify more decimals using the FORMAT_FLOAT_OUT setting.
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 reduce the remote high-resolution GSHHG polygon for Australia down to a tolerance of 500 km, use:
gmt simplify @GSHHS_h_Australia.txt -T500k
To reduce the Cartesian lines xylines.txt using a tolerance of 0.45 and write the reduced lines to file new_xylines.txt, run:
gmt simplify xylines.txt -T0.45 > new_xylines.txt
There is a slight difference in how simplify processes lines versus closed polygons. Segments that are explicitly closed will be considered polygons, otherwise we treat them as line segments. Hence, segments recognized as polygons may reduce to a 3-point polygon with no area; these are suppressed from the output.
One known issue with the Douglas-Peucker has to do with crossovers. Specifically, it cannot be guaranteed that the reduced line does not cross itself. Depending on how many lines you are considering it is also possible that reduced lines may intersect other reduced lines. Finally, the current implementation only does Flat Earth calculations even if you specify spherical; simplify will issue a warning and reset the calculation mode to Flat Earth.
Douglas, D. H., and T. K. Peucker, Algorithms for the reduction of the number of points required to represent a digitized line of its caricature, Can. Cartogr., 10, 112-122, 1973.
This implementation of the algorithm has been kindly provided by Dr. Gary J. Robinson, Department of Meteorology, University of Reading, Reading, UK; his subroutine forms the basis for this program.