Skip to content

pygmt.grdmask: Create mask grid from polygons or point coverage(required arguments)#4428

Open
Chuan1937 wants to merge 34 commits intoGenericMappingTools:mainfrom
Chuan1937:grdmask1
Open

pygmt.grdmask: Create mask grid from polygons or point coverage(required arguments)#4428
Chuan1937 wants to merge 34 commits intoGenericMappingTools:mainfrom
Chuan1937:grdmask1

Conversation

@Chuan1937
Copy link
Member

@Chuan1937 Chuan1937 commented Feb 25, 2026

pygmt.grdmask: Create mask grid from polygons or point coverage(required arguments)

Preview: https://pygmt-dev--4428.org.readthedocs.build/en/4428/api/generated/pygmt.grdmask.html#pygmt.grdmask

@Chuan1937 Chuan1937 changed the title pygmt.grdmask: Create mask grid from polygons or point coverage pygmt.grdmask: Create mask grid from polygons or point coverage(required arguments) Feb 25, 2026
@Chuan1937 Chuan1937 self-assigned this Feb 25, 2026
Chuan1937 and others added 3 commits February 25, 2026 22:01
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Chuan1937 and others added 2 commits February 25, 2026 22:21
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@Chuan1937 Chuan1937 requested a review from seisman February 26, 2026 05:40
@Chuan1937 Chuan1937 requested a review from seisman March 2, 2026 03:29
Chuan1937 and others added 4 commits March 2, 2026 17:53
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Chuan1937 and others added 3 commits March 3, 2026 10:16
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@Chuan1937 Chuan1937 requested a review from seisman March 3, 2026 02:27
Chuan1937 and others added 5 commits March 3, 2026 14:43
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@Chuan1937 Chuan1937 requested a review from seisman March 4, 2026 02:07
@seisman seisman added feature Brand new feature needs review This PR has higher priority and needs review. labels Mar 4, 2026
@seisman seisman added this to the 0.19.0 milestone Mar 4, 2026
Chuan1937 and others added 6 commits March 4, 2026 12:22
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Chuan1937 and others added 4 commits March 4, 2026 15:14
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Comment on lines +32 to +33
>>> _alias_option_N(outside=0, edge=0, inside=1)._value
'0/0/1'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_alias_option_N() should return None.

Suggested change
>>> _alias_option_N(outside=0, edge=0, inside=1)._value
'0/0/1'
>>> _alias_option_N()._value

Comment on lines +36 to +45
>>> _alias_option_N(outside=0, edge=0, inside="z")._value
'z'
>>> _alias_option_N(outside=1, edge=0, inside="z")._value
'z/1'
>>> _alias_option_N(outside=0, edge="z", inside="z")._value
'Z'
>>> _alias_option_N(outside=0, edge=0, inside="id")._value
'p'
>>> _alias_option_N(outside=0, edge="id", inside="id")._value
'P'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>> _alias_option_N(outside=0, edge=0, inside="z")._value
'z'
>>> _alias_option_N(outside=1, edge=0, inside="z")._value
'z/1'
>>> _alias_option_N(outside=0, edge="z", inside="z")._value
'Z'
>>> _alias_option_N(outside=0, edge=0, inside="id")._value
'p'
>>> _alias_option_N(outside=0, edge="id", inside="id")._value
'P'
>>> _alias_option_N(inside="z")._value
'z'
>>> _alias_option_N(outside=1, inside="z")._value
'z/1'
>>> _alias_option_N(edge="z", inside="z")._value
'Z'
>>> _alias_option_N(inside="id")._value
'p'
>>> _alias_option_N(edge="id", inside="id")._value
'P'

Comment on lines +57 to +61
# Mode: -Nz, -NZ, -Np, or -NP
mode_char = _inside_modes[inside]
if edge == inside:
mode_char = mode_char.upper()
mask_values = mode_char if outside is None else [mode_char, outside]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Mode: -Nz, -NZ, -Np, or -NP
mode_char = _inside_modes[inside]
if edge == inside:
mode_char = mode_char.upper()
mask_values = mode_char if outside is None else [mode_char, outside]
# Mode: -Nz, -NZ, -Np, or -NP
mode = _inside_modes[inside]
if edge == inside:
mode = mode.upper()
mask_values = mode if outside is None else [mode, outside]

"""
Create mask grid from polygons or point coverage.

Reads one or more files (or standard input) containing polygon or data point
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no standard in in Python.

Suggested change
Reads one or more files (or standard input) containing polygon or data point
Reads one or more files containing polygon or data point

Create mask grid from polygons or point coverage.

Reads one or more files (or standard input) containing polygon or data point
coordinates, and creates a binary grid file where nodes that fall inside, on the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
coordinates, and creates a binary grid file where nodes that fall inside, on the
coordinates, and creates a grid where nodes that fall inside, on the

Comment on lines +108 to +109
Pass in either a file name, :class:`pandas.DataFrame`, :class:`numpy.ndarray`,
or a list of file names containing the polygon(s) or data points. Input can be:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Pass in either a file name, :class:`pandas.DataFrame`, :class:`numpy.ndarray`,
or a list of file names containing the polygon(s) or data points. Input can be:
Pass in either a file name to an ASCII data table, a 2-D $table_classes
containg the polygon(s) or data points. Input can be:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Brand new feature needs review This PR has higher priority and needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants