Skip to content

Improve support for categorical CPTs - #4446

Merged
PaulWessel merged 7 commits into
masterfrom
improv-cat-cpt
Nov 13, 2020
Merged

PaulWessel merged 7 commits into
masterfrom
improv-cat-cpt

Conversation

@PaulWessel

Copy link
Copy Markdown
Contributor

Description of proposed changes

See this forum post for one aspect of this PR.

This PR does two things:

  1. Fixes the problem that required an extra z-value in -T to get correct categorical CPT output.
  2. Simplifies how one may add categorical keys rather than using numerical look-up values via new -F modifier +kkeys.

Like +c for categorical labels, +k can create sequential keys (such as G, H, I, ...) if just given one letter, it can read a list of keys from the file keys, or it is decoded as a comma-separated list of keys.

To make a categorical cpt for use with plot to plot polygons what have multi-segment headers with -Z entries A, B, or C that stands for wood, water, gold, one can run

gmt makecpt -Ccategorical -T0/2/1 -F+cWood,Water,Gold+kA              
A	green	L	;Wood
B	blue	L	;Water
C	red	B	;Gold
N	127.5

for a suitable CPT.

We recently made it simpler to add CPT labels via -F+c.  Now, we use a similar mechanism to add string keys to replace numerical look up values for cateborical CPTs via -F+kkeys.  A few more checks on the number of labels and keys were added as well.  Fixed the bug where a categorical request for -T1/n/1 did not include n.
@PaulWessel PaulWessel self-assigned this Nov 11, 2020

@weiji14 weiji14 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great enhancement! I can't comment on the code, but did spot a typo?

Comment thread doc/rst/source/makecpt.rst Resolved
Comment thread src/grd2cpt.c Resolved
@PaulWessel

Copy link
Copy Markdown
Contributor Author

Please give this another look and hopefully approve.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants