Run modulus formula in GMS 16.2.2
George Chandeep Corea
Global Mapper UserPosts: 62Trusted User
I need to create a contour_type field for major (5m intervals), moderate (1m intervals) and minor (others).
In QGIS I run the following in my script
In QGIS I run the following in my script
CASE WHEN "elevation" % 1 THEN 'minor'
WHEN "elevation" % 5 THEN 'moderate'
ELSE 'major'
END
How do I do the same in GMS?
I think it will be something like
// Create new contour_type attribute
IF COMPARE_STR="elevation%1"= 0
CALC_ATTR_FORMULA NEW_ATTR="contour_type2" FORMULA="moderate"
ELSE IF COMPARE_STR="elevation%5"= 0
CALC_ATTR_FORMULA NEW_ATTR="contour_type2" FORMULA="major"
ELSE
CALC_ATTR_FORMULA NEW_ATTR="contour_type2" FORMULA="minor"
So if the contour is
1.25m then modulus for 1 and 5 is not 0 (no remainder) and is therefore minor
2m then modulus for 1 is 0 but not for 5 so it is moderate
10m modulus for 5 is 0 but not for 1 so it is major
Also how do I move the elevation field and the new contour_type fields to be the first and second columns in the table?
Tagged:
Best Answer

bmg_bob Global Mapper Programmer Posts: 2,218The DEFINE_VAR and CALC_ATTR_FORMULA script commands support calculation of the remainder via the MOD function. See the description for the FORMULA parameter, and a link to the Formula Calculator Reference.
Answers
If GMS can't do this is there an alternative way of getting the remainder?
Here's what I used.