Skip to content

Subset grid using a geopandas.GeoDataFrame polygon with grdcut -F #1529

Open

Description

@weiji14

Description of the desired feature

Spatial subsetting/cropping/masking/clipping of a raster grid using a polygon (stored in an ESRI shapefile or geopandas.GeoDataFrame) is a common operation, e.g. to extract a Region of Interest.

Currently, the pygmt.grdcut function in PyGMT v0.4.1 (added in #492) can do bounding box (via 'region' -R), circular (via 'circ_subregion' -S) and z-value (via 'z_subregion' -Z) based subsetting.

It would be nice to add in the grdcut -F option too which does polygon-based crops using an ASCII file. Furthermore, it would be even nicer to perform the crop using an in-memory geopandas.GeoDataFrame or shapely.geometry polygon object!

Technically, this is reinventing the wheel, because there are a few Python libraries that already do this:

But who says the wheel can't be reinvented 😄

Are you willing to help implement and maintain this feature? A bit low on my priority list, but anyone interested is welcome to try.

Steps to implement:

Activity

  1. added
    feature request
    on Sep 21, 2021
  2. added this to the 0.6.0 milestone on Sep 21, 2021
  3. added
    good first issue
    help wanted
    on Sep 21, 2021
  4. modified the milestones: 0.6.0, 0.7.0 on Mar 1, 2022
  5. modified the milestones: 0.7.0, 0.8.0 on Jun 17, 2022
  6. modified the milestones: 0.8.0, 1.0.0 on Sep 20, 2022
  7. removed
    good first issue
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requesthelp wanted

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions