Skip to content

Enhanced node determination in grdmask for polygon input#6289

Merged
PaulWessel merged 6 commits intomasterfrom
grdmask-pol-selection
Feb 1, 2022
Merged

Enhanced node determination in grdmask for polygon input#6289
PaulWessel merged 6 commits intomasterfrom
grdmask-pol-selection

Conversation

@PaulWessel
Copy link
Member

This PR adds a new -Cmode option to grdmask, more or less the same -C option offered in grdblend. There, it controls which grids contribute to the final output node (instead of blending, a single grid's node will prevail) while here it selects the single polygon whose z-value sets the node. The -C option determines which polygon:

  1. -Cf: The first polygon to cover a node sets the node value.
  2. -Co The last polygon to cover a node sets the node value. [Default]
  3. -Cl: The polygon with lowest z-valueto cover a node sets the node value.
  4. -Cu: The polygon with highest z-valueto cover a node sets the node value.

The actual z-value is controlled by -N. With default -Co we retain backwards compatibility while other modes offer new capabilities. A new script (maskmode.sh based on ogrtest.sh) was added which shows the output for the 4 different modes. I used awk to shuffle some polygon z-values so that the effect of all modes can be seen:

maskmode

@PaulWessel PaulWessel added the new core module feature PR that implements a new core module feature label Jan 31, 2022
@PaulWessel PaulWessel added this to the 6.4.0 milestone Jan 31, 2022
@PaulWessel PaulWessel requested a review from maxrjones January 31, 2022 23:14
@PaulWessel PaulWessel self-assigned this Jan 31, 2022
@maxrjones maxrjones added the add-changelog Add PR to the changelog label Jan 31, 2022
@maxrjones
Copy link
Member

I think this sentence in the module description should be updated to acknowledge the option to have more values in the output grid with -Nz:

The nodes defined by the specified region and lattice spacing will be set equal to one of three possible values depending on whether the node is outside, on the polygon perimeter, or inside the polygon.

@PaulWessel
Copy link
Member Author

OK, made a change.

@PaulWessel PaulWessel merged commit 1ae97b6 into master Feb 1, 2022
@PaulWessel PaulWessel deleted the grdmask-pol-selection branch February 1, 2022 02:04
/* Here we will have to consider the x coordinates as well (or known_side is set) */
#ifdef _OPENMP
#pragma omp parallel for private(col,xx,side,ij) shared(n_columns,GMT,Grid,do_test,yy,S,known_side,row,Ctrl,z_value,mask_val)
#pragma omp parallel for private(col,ij,xx,side,z_to_set) shared(n_columns,Grid,row,Ctrl,node_is_set,GMT,do_test,yy,S,known_side,z_value,mask_val)
Copy link
Member

Choose a reason for hiding this comment

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

The new test maskmode.sh fails on Linux when OpenMP support enabled. I have not checked if it's the same on macOS, but I would assume so. There's also a compiler warning that z_to_set may be uninitialized. @PaulWessel do you notice anything obvious wrong with the OpenMP implementation here? Otherwise I can debug.

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

Labels

add-changelog Add PR to the changelog new core module feature PR that implements a new core module feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants