Problem with formula calculation

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
-
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
-
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.
-
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
-
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.
Categories
- 12.4K All Categories
- 5.4K Features Discussion
- 314 Downloading Imagery
- 1.3K Elevation Data
- 377 Georeferencing Imagery Discussion
- 603 GM Script Language
- 49 User Scripts
- 112 GPS Features
- 394 Projection Questions
- 800 Raster Data
- 1.3K Vector Data
- 6.5K Support
- 161 Announcement and News
- 890 Bug Report
- 556 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 537 Other Discussion
- 128 GIS Data Sources
- 26 Global Mapper Showcase
- 224 How I use Global Mapper
- 104 Global Mapper Forum Website