Feature #1256

Custom symbols: Make all input columns available inside the symbol for conditional testing

Added by Kristof 3 months ago. Updated 2 months ago.

Status:ResolvedStart date:2018-07-06
Priority:NormalDue date:
Assignee:Paul% Done:


Target version:Candidate for next minor release


In reference to the thread Custom Symbols: Is there a way to access LON/LAT from ''inside'' the symbol? in the GMT user forum.

Dear Gurus,

in my opinion it would be a useful addition to the custom symbol macro language to make all columns of the input file available inside the symbol for conditional testing.

  • X/LON can be used for different symbols depending if they are in the eastern or western hemisphere like custom annotations which should not reproduce the exact value of X.
  • Y/LAT is useful for symbols which have a different appearance on the northern or southern hemisphere like for example wind barbs or symbols for low and high pressure systems.
  • SIZE offers the possibility to plot a simplified symbol if the plotted size is small or a more detailed symbol if the selected size is bigger.

In the latest version of GMT the values for X/LON and Y/LAT are available as strings for text replacement (as %X and %Y) but, as Paul stated in the thread, they can't be tested against. The current solution is to duplicate the required values as separate columns in the input file and feed them as separate variables into the symbol. While this works it is somewhat inelegant as you have to duplicate data which is already in the input file.

My feature request therefore:

Make all values from the input file available inside the symbol for conditional testing.

Thank you and all the best,

Associated revisions

Revision 20390
Added by Paul 3 months ago

Added and for conditional testing in response to issue #1256


#1 Updated by Paul 3 months ago

  • Status changed from New to Resolved
  • Assignee set to Paul
  • Target version set to Candidate for next minor release
  • % Done changed from 0 to 100

Was easier than I thought. I implemented the use of $x and $y to complement $1, $2, etc.. Note $x, if longitude, is not given any special treatment in the conditional tests such as checking for 360-degree periodicity in any test you may write. In r20390 (and trunk only since a new feature).

#2 Updated by Kristof 3 months ago

Thank you for the quick implementation. Any chance to get access to SIZE as well?

#3 Updated by Paul 3 months ago

OK, try testing with $s. Note any constant you compare it to should have proper units, e.g. 2c or 0.5i since internally, everything is in inches and 2 may be converted to inches or cm depending on PROJ_LENGH_UNIT. Best to add the units in the macro. r20398 (trunk only).

#4 Updated by Kristof 3 months ago

Thank you, Paul! I’ll take it for a test drive. Good to know that everything inside is in inches.

#5 Updated by Kristof 2 months ago

Hi Paul,

  • $X & $Y
    The new variables $X and $Y are working great for me. Thank you.
  • $S
    I was unable to get it to work. The symbol
    if $S >= 1c then {
    0 0 1c a
    } else {
    0 0 1c g

    always goes into the else part with 1c symbol size in the input file. Where am I making a mistake? I tried both $s and $S.

I tested it with 6.0.0_r20409

Thank you and all the best,

#6 Updated by Paul 2 months ago

Hm, works for me. If I use your symbol above and the file t.txt
-1 -1 0.9c
1 1 1.0c
gmt psxy -R-2/2/-2/2 -JX4i -P -Bafg -Skwhat t.txt > t.ps
gives a star and an octagon.

Also available in: Atom PDF