# Run modulus formula in GMS 16.2.2

edited December 2015
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
`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 attributeIF COMPARE_STR="elevation%1"= 0CALC_ATTR_FORMULA NEW_ATTR="contour_type2" FORMULA="moderate"ELSE IF COMPARE_STR="elevation%5"= 0CALC_ATTR_FORMULA NEW_ATTR="contour_type2" FORMULA="major"ELSECALC_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:

• Global Mapper Programmer Posts: 2,218
The 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.

`/create modulus columns for 1m and 5mCALC_ATTR_FORMULA NEW_ATTR="modulus1m" FORMULA="MOD(ELEVATION,1)"CALC_ATTR_FORMULA NEW_ATTR="modulus5m" FORMULA="MOD(ELEVATION,5)"/ Create new contour_type attributeEDIT_VECTOR COMPARE_STR="modulus1m=0" ATTR_VAL="contour_type=moderate"EDIT_VECTOR COMPARE_STR="modulus5m=0" ATTR_VAL="contour_type=major"EDIT_VECTOR COMPARE_STR="modulus1m!=0" ATTR_VAL="contour_type=minor"`