gmtconnect man page
gmtconnect — Connect individual lines whose end points match within tolerance
gmtconnect [ table ] [ -C[closed] ] [ -D[template] ] [ -L[linkfile] ] [ -Q[template] ] [ -T[cutoff[unit][/nn_dist]] ] [ -V[level] ] [ -bbinary ] [ -dnodata ] [ -eregexp ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -oflags ] [ -:[i|o] ]
Note: No space is allowed between the option flag and the associated arguments.
gmtconnect reads standard input or one or more data files, which may be multisegment files, and examines the coordinates of the end points of all line segments. If a pair of end points are identical or closer to each other than the specified separation tolerance then the two line segments are joined into a single segment. The process repeats until all the remaining endpoints no longer pass the tolerance test; the resulting segments are then written out to standard output or specified output file. If it is not clear what the separation tolerance should be then use -L to get a list of all separation distances and analyze them to determine a suitable cutoff.
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.
Write all the closed polygons to closed [gmtconnect_closed.txt] and all other segments as they are to stdout. No connection takes place. Use -Tcutoff to set a minimum separation , and if cutoff is > 0 then we also explicitly close the polygons on output.
For multiple segment data, dump each segment to a separate output file [Default writes a single multiple segment file]. Append a format template for the individual file names; this template must contain a C format specifier that can format an integer argument (the segment number); this is usually %d but could be %08d which gives leading zeros, etc. Optionally, it may also contain the format %c before the integer; this will then be replaced by C (closed) or O (open) to indicate segment type. [Default is gmtconnect_segment_%d.txt]. Note that segment headers will be written in either case. For composite segments, a generic segment header will be written and the segment headers of individual pieces will be written out as comments to make it possible to identify where the connected pieces came from.
Writes the link information to the specified file [gmtconnect_link.txt]. For each segment we write the original segment id, and for the beginning and end point of the segment we report the id of the closest segment, whether it is the beginning (B) or end (E) point that is closest, and the distance between those points in units determined by -T.
Used with -D to a list file with the names of the individual output files. Optionally, append a filename template for the individual file names; this template may contain a C format specifier that can format an character (C or O for closed or open, respectively). [Default is gmtconnect_list.txt].
Specifies the separation tolerance in the data coordinate units ; append distance unit (see Units). If two lines has end-points that are closer than this cutoff they will be joined. Optionally, append /nn_dist which adds the requirement that a link will only be made if the second closest connection exceeds the nn_dist. The latter distance must be given in the same units as cutoff. However, if no arguments are given then we close every polygon regardless of the gap between first and last point.
- -V[level] (more ...)
Select verbosity level [c].
- -bi[ncols][t] (more ...)
Select native binary 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]z[+|-]gap[u] (more ...)
Determine data gaps and line breaks.
- -h[i|o][n][+c][+d][+rremark][+rtitle] (more ...)
Skip or produce header record(s).
- -icols[+l][+sscale][+ooffset][,...] (more ...)
Select input columns and transformations (0 is first column).
- -ocols[,...] (more ...)
Select output columns (0 is first column).
- -:[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 exits (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 exits.
- -? or no arguments
Print a complete usage (help) message, including the explanation of all options, then exits.
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. Prepend - to a distance (or the unit is no distance is given) to perform "Flat Earth" calculations (quicker but less accurate) or prepend + to perform exact geodesic calculations (slower but more accurate).
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.
To combine the digitized segment lines segment_*.txt (whose coordinates are in cm) into as few complete lines as possible, assuming the end points slop could be up to 0.1 mm, run
gmt connect segment_*.txt -Tf0.1 > new_segments.txt
To combine the digitized segments in the multisegment file my_lines.txt (whose coordinates are in lon,lat) into as few complete lines as possible, assuming the end points slop could be up to 150 m, and write the complete segments to separate files called Map_segment_0001.dat, Map_segment_0002.dat, etc., run
gmt connect my_lines.txt -T150e -DMap_segment_%04d.dat
The line connection does not work if a line only has a single point. However, gmtconnect will correctly add the point to the nearest segment. Running gmtconnect again on the new set of lines will eventually connect all close lines.
gmt, gmt.conf, gmtsimplify, gmtspatial, mapproject
2017, P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis, and F. Wobbe