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.grdcut method 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/grdcut.html
- GMT.jl: https://www.generic-mapping-tools.org/GMTjl_doc/documentation/modules/grdcut
- PyGMT: https://www.pygmt.org/dev/api/generated/pygmt.grdcut.html
GMT Option Flags and Modifiers
☑️: Implemented; ⬜: To be implemented/discussed; Strikethrough: Won't implement.
- ☑️
-G(outgrid): Output grid or image file; if unset, returns anxarray.DataArray. - ☑️
-J(projection): Oblique map projection used to determine the equivalent rectangular region. - ☑️
-N(extend): Allow the grid to be extended beyond its current boundaries; optionally specify a fill value for new nodes. - ☑️
-R(region): Define the subregion to extract. - ☑️
-S(circ_subregion): Define a circular subregion by origin (lon/lat) and radius; append+nto NaN-fill nodes outside the circle. - ☑️
-V(verbose): Verbosity level. - ☑️
-Z(z_subregion): Shrink the region to the bounding box of nodes within a given z-range; supports+n,+N, and+rmodifiers. - ☑️
-f(coltypes): Specify column data types for coordinate interpretation. : Use-X/-YFigure.shift_origininstead.: Use--PAR=valuepygmt.configinstead.
Notes on Input Formats
grid: Accepts a file path orxarray.DataArray. When a file path is given, thekindparameter must be set to"grid"(default) or"image"to disambiguate the input type.kind: PyGMT-specific parameter (not a GMT flag) that specifies whether the raster is a grid or an image. When the input is anxarray.DataArray, the kind is detected automatically.region: Must not exceed the input grid's extent unlessextendis set.circ_subregion: Appending+nNaN-fills all nodes outside the circle while preserving the rectangular bounding-box shape of the output grid.z_subregion: Use"-"as min or max to leave that bound unconstrained. The+Nmodifier first strips NaN-only border rows/columns, then (optionally) applies the z-range test.- Returns
xarray.DataArraywhenoutgridis unset; returnsNonewhenoutgridis a file path.
Linked Pull Requests
- Initial feature implementation – Wrap grdcut #492
- Accept
xarray.DataArrayas input – Let grdcut() accept xarray.DataArray as input #541 - Ensure GMTDataArray accessor info is propagated – Ensure surface and grdcut loads GMTDataArray accessor info into xarray #539
- Refactor to store output in virtualfiles – **BREAKING** pygmt.grdcut: Refactor to store output in virtualfiles for grids #3115
- Add inline docstring example – Add inline example for grdcut #1689
- Add a gallery or tutorial example demonstrating region extraction (e.g., cutting out a country or ocean basin from a global relief grid)
- Consider exposing image-mode cutting more explicitly in documentation/examples
Related Issues and Discussions
- Closely related to
pygmt.grdselect(filter grids by metadata criteria) andpygmt.grdsample(resample to a new grid layout). - For non-rectangular spatial masking, consider combining
grdcutwithpygmt.grdmask. - The
kind="image"path allows cutting RGB images (e.g., GeoTIFFs), making this useful beyond purely scientific grid data.
Metadata
Metadata
Assignees
Labels
feature requestNew feature wanted
Type
Projects
- StatusShow more project fieldsNo status
Activity