Global Mapper v24.1

Problem with formula calculation

JSL
JSL Global Mapper UserTrusted User

Help, what am I doing wrong here? I'm trying to calc attr an "if" expression comparing one attribute to 0, so I use this expression:

if(num(MAX ELEV AVG OF LAYER DIFF FROM MAX ELEV)<0,"lesser","greater")

I copied the formula directly from the "if" example in the Formula Help menu and substituted my variable names, but I'm getting this error:

"Missing '(' in function argument list"

Best Answer

  • JeffH@BMG
    JeffH@BMG Global Mapper Developer Trusted User
    Answer ✓

    Hi JSL,

    Not sure why combining areas isn't directly supported in the scripting language. I was thinking that you could do this using the EDIT_VECTOR command (https://www.bluemarblegeo.com/knowledgebase/global-mapper-24/cmd/EDIT_VECTOR.htm), but couldn't come up with anything that works.

    You could try something like the following, which uses the spatial operations scripting language embedded in a Global Mapper script:

    BEGIN_SPATIAL_OPERATION

    layer "Result" = dissolve( "Areas_1.shp" )

    END_SPATIAL_OPERATION

    Hope that this helps,

    ~Jeff

Answers

  • JSL
    JSL Global Mapper User Trusted User

    I figured out the problem--the formula calculator doesn't like spaces, so I just needed to put a "_" between the words in my formula.

  • JeffH@BMG
    JeffH@BMG Global Mapper Developer Trusted User

    Hi JSL,

    It's true: the formula calculator, much like most programming languages, doesn't like embedded spaces in variable names (or attribute names, in this case) -- it makes parsing a formula harder. But you should be able to enclose the name with percent characters ('%') in the formula, and that should work fine. In your case, the formula would be: if(num(%MAX ELEV AVG OF LAYER DIFF FROM MAX ELEV%)<0,"lesser","greater").

    See the online docs: https://www.bluemarblegeo.com/knowledgebase/global-mapper-24/Scripting_Reference/Formula_Calculator.htm, specifically the section Formula Reference / Values / Attributes (for the Attribute Calculator and CALC_ATTR_FORMULA command only), which discusses this specifically (i.e., buried in the fine print, a bit).

    Hope that this helps.

    Cheers,

    ~Jeff

  • JSL
    JSL Global Mapper User Trusted User

    Thanks, I always wondered what the reason was for the underscore. I'm using this knowledge to play around with scripting, and I was wondering if there was a script for combining areas? I see combining lines in the Knowledge Base, but not combining areas.