# Replace elevation value

Global Mapper UserPosts: 6
hi,
how can i do elevation value  from -3 to +3 , reassign to Zero
the value between -3 ~ +3 will output as zero
FORMULA=if(-3<B1<3,0,B1)
i need the correct GM Script language sample

thanks
Best Regard.

suzuki

Tagged:

• Global Mapper User Posts: 171
Nested conditional?

if(elevation<-3,elevation,(if(elevation>3,elevation,0)

• Global Mapper User Posts: 6
Dear Geomannie :
that's really great solution!!
thanks a lot ,

• Global Mapper Developer Posts: 269Trusted User

You can also accomplish the same thing using the formula: if( elevation < 3 and elevation > -3. 0, elevation ), or equivalently, if ( elevation < 3 & elevation > -3, 0, elevation )

Cheers,

~Jeff
• Global Mapper Developer Posts: 269Trusted User
By the way, I don't believe that a formula like "if(-3<B1<3,0,B1)" works in Excel either, which is more or less what the Global Mapper formula calculator tries to emulate. The formula will parse fine (both in Excel and in Global Mapper), but  it won't be interpreted in the way that's intended. Essentially, the way that "-3 < B1 < 3" is interpreted is by first evaluating whether B1 is greater than -1, which yields a Boolean result (0 or 1 under the hood), and then evaluating whether that Boolean result is < 3 (which it always is).

Modifying the grammar to handle this type of construct could probably be done, but it's a little tricky, and then it also wouldn't work in the same way that Excel formulas do.

Best regards,

~Jeff