Repository navigation
Closed
Labels
feature requestNew feature wanted
Description
This issue serves as the central place for discussing and tracking the implementation of the pygmt.triangulate class in PyGMT. The issue will be closed when the initial implementation is complete. Progress is tracked at PyGMT: Wrapping GMT modules.
Documentation
- GMT: https://docs.generic-mapping-tools.org/dev/triangulate.html
- GMT.jl: https://www.generic-mapping-tools.org/GMTjl_doc/documentation/modules/triangulate
- PyGMT: https://www.pygmt.org/dev/api/generated/pygmt.triangulate.html
GMT Option Flags and Modifiers
☑️: Implemented; ⬜: To be implemented/discussed; Strikethrough: Won't implement.
- ⬜
-Cslpfile: Read a slope grid (in degrees) from slpfile and use it to constrain the surface slope at data points. Only available if the Shewchuk algorithm is installed. - ⬜
-D[x|y]: Take the derivative of the surface in the x or y direction at each node. - ⬜
-Eempty: Set the value assigned to empty nodes when-Gis set [Default is NaN]. - ⬜
-F: Do not remove duplicate input data points [Default removes duplicates]. - ☑️
-G(outgrid): Output grid file name (triangulate.regular_gridonly). - ☑️
-I(spacing): Grid spacing (triangulate.regular_gridonly). - ☑️
-J(projection): Map projection. - ⬜
-M: Output triangle edges as multiple-segment files suitable for GMT plotting. - ⬜
-N: Output the triplets of point IDs that form each triangle in a separate file. - ⬜
-Q[n]: Produce Voronoi polygon output instead of (or in addition to) Delaunay triangulation output. Only available if the Shewchuk algorithm is installed. Optionally append n to avoid long polygon arcs crossing the map. - ☑️
-R(region): Define the region. - ⬜
-S: Output the area of each triangle, followed by the centre longitude and latitude, in a separate file. - ⬜
-T: Output triangle edges as line segments rather than vertex triplets. Useful for plotting. - ☑️
-V(verbose): Verbosity level. : Use-X/-YFigure.shift_origininstead.- ☑️
-b(binary): Binary input/output. - ☑️
-d(nodata): Replace NaN with a specified nodata value on input/output. - ☑️
-e(find): Pattern matching to select input rows. - ☑️
-f(coltypes): Column data types. - ☑️
-h(header): Read/write header records. - ☑️
-i(incols): Select input columns. - ☑️
-r(registration): Set grid node registration to gridline or pixel. - ☑️
-s(skiprows): Skip rows containing NaN values. - ☑️
-w(wrap): Wrap repeated cycles. : Use--PAR=valuepygmt.configinstead.
Notes on Input Formats
data: Accepts a file path, 2-Dnumpy.ndarray, orpandas.DataFramewith at least 2 columns (x, y) or 3 columns (x, y, z). Alternatively, providex,y, and optionallyzas separate 1-D arrays.triangulate.regular_grid: Returns anxarray.DataArrayifoutgridisNone, otherwiseNone. Requiresspacingandregion.triangulate.delaunay_triples: Returns apandas.DataFrameornumpy.ndarraycontaining the index triplets of each triangle.output_typeandoutfilecontrol the output format.- The availability of the Shewchuk [1996] algorithm (needed for
-C,-Q) can be checked withgmt get GMT_TRIANGULATEon the command line. - For geographic data with large spatial extent, use
pygmt.sphtriangulateinstead, astriangulateis a Cartesian operator unaware of polar or periodic boundary conditions.
Linked Pull Requests
- Initial feature implementation – Wrap triangulate #731
- Refactor to use codes consistent with other wrappers – pygmt.triangulate: Refactor to use codes consistent with other wrappers #3073
- Implement
-E(empty node value) option forregular_grid - Implement
-M(multiple-segment output) option fordelaunay_triples - Implement
-N(output node info to separate file) option fordelaunay_triples - Implement
-Q(Voronoi polygon output) option fordelaunay_triples - Implement
-S(triangle area and centroid) option fordelaunay_triples - Implement
-T(edge output) option fordelaunay_triples - Add a gallery or tutorial example (e.g., Delaunay triangulation of a sparse point set and overlaying it on a map, or comparing triangulation-based gridding with
pygmt.surface)
Related Issues and Discussions
pygmt.triangulate.delaunay_triplesis commonly used as the first step in custom mesh generation workflows or to compute triangle-based statistics (e.g., triangle areas or centroid locations).- The Voronoi option (
-Q) provides a dual tessellation from the same input points as the Delaunay triangulation; this is useful for nearest-neighbour region assignment. - For geographic or global spherical data, prefer
pygmt.sphtriangulateandpygmt.sphdistanceoverpygmt.triangulate.
Metadata
Metadata
Assignees
Labels
feature requestNew feature wanted
Type
Projects
- StatusShow more project fieldsNo status
Activity