Global Mapper v25.0

what is wrong with this formula?

I have run the "chainage" tool on a set of points that are close to a line so that the point attributes now include DIST_TO_LINE and SIDE_OF_LINE. SIDE_OF_LINE is either "L" or "R".

I want to convert the distances on the left side to negative so have created a calculation for a new attribute "OFFSET" which is calculated using the following


When I run this, all OFFSETS end up being negative.

When testing, it seems as that the IF statement isn't working. The second option never gets applied. I tried it with the "extra" brackets and without. Also IF and if.


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

    Hi Ron,

    Not sure what's going on with that particular formula -- it looks fine, and it should work, though. I made up an example in version 24.0, and it appeared to work fine. Not sure what version you're using; it might help to add that information here.

    Beyond that, it looks like you're looking to make the new OFFSET attribute always be positive. In that case, you should be able to use the following simpler formula that takes the absolute value of the distance, and is always greater than or equal to 0:


    I'll note that I wrote the original extended formula stuff, but I'm not working for Blue Marble any longer, so I don't have access to the code for debugging purposes, and I don't have a more recent version of Global Mapper.

    Hope that this helps,


  • Hi Jeff,

    Thanks for looking at it.

    I am also using 24.0.

    To clarify, I am trying to make a new OFFSET negative if the it is on the left side of the line (SIDE_OF_LINE = L), otherwise it will stay as it is (positive).

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

    Hi again - OK, still unable to replicate the problem. I did this:

    Loaded a .shp file consisting of areas that I had handy. The file had, for each polygon, a 'SHAPE_AREA' attribute. In order to make a SIDE_OF_LINE attribute, I used the following, somewhat arbitrary, formula: if ( Shape_Area < 100000, "L", "R" ). This resulted in some labelled with 'L', and the rest with 'R',

    Then I tried a number of variations to add a OFFSET attributes, to test other scenarios: using "L" rather than 'L', removing extraneous parentheses, using a simpler result, etc.:




    These all worked as expected: each of the new attributes (e.g. 'OFFSET', 'OFFSET2', 'OFFSET3', etc.) all had negative values when its associated 'SIDE_OF_LINE' attribute was 'L' (or "L").

    I'm a bit at a loss to explain what's happening in your case.


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

    One more thing --

    I wasn't familiar with the chainage stuff, so I looked into it and figured out how to do it. Loaded a point layer, and created a new line that ran through the point layer. Then I selected all the points and the line, and ran the chainage functionality, and wound up with a new layer of line (which are irrelevant to our example). Looked at the point layer's attributes, and saw that the SIDE_OF_LINE and DIST_FROM_LINE attributes had been added, with some SIDE_OF_LINE attributes being 'L', and the others 'R'. So far so good.

    Then I opened up the attribute calculator on the point layer, and ran the exact formula that you gave initially (IF((SIDE_OF_LINE = 'L'), (-1*DIST_FROM_LINE),(DIST_FROM_LINE))) being used to generate a new OFFSET attribute.. This resulted in a OFFSET values that were negative for items with the SIDE_OF_LINE = 'L', and positive for the others.

    So again, this seems to be working. This is in version v24.0 (b072922). I'm a puzzled as to why it's not working for you.

    best regards,