3

i want to display the current chainage of a line in a certain interval (say every 100m). I know this can be done for instance by the plungin Qchainage or LRS. But the labels have to be displayed orthogonally to the current line bearing, which none of these tools do provide fields for. Considering the advanced labelling options i know i can set labels (even with flexible bearing option) at certain intervals but I did not find an option (expression) to display the respective position of a line.

Is there a straight forward way to solve an issue like I delineated?

2

I got something close using QGIS 2.16.

It needs some additional work / experimentation, but hopefully give you a starting point. I'm not sure how best to add an offset, but you might be able to hack it by padding the label text with spaces ;-)

enter image description here

I'm using epsg:27700, a local UTM CRS in meters, so units are in meters.

To do this, added a new field on the output of QChainage using the expression

180.0 - degrees(
    azimuth(
        start_point(
            intersection(
                geometry(
                    get_feature('my_line_layer','field',value)
                ), 
                buffer( $geometry,5)
            )
        ),
        end_point(
            intersection(
                geometry(
                    get_feature('my_line_layer','field',value)
                ), 
                buffer( $geometry,5)
            )
        )
    )
)

In more detail, this...

  • buffers each chainage point by 5 meters
  • then gets the buffer intersection with the line, which is a feature in another layer (here, a bus route). You'll need a unique field that you can look up. This should (hopefully) give a line.
  • measures the azimuth between the start and end of the line
  • converts to degrees (which is what the labelling expects).
  • subtract from 180 to make it orthogonal

You should then be able to use this field as the 'rotation' value for your labels.

  • Thanks a lot Steven for this great solution! It seems complicated but certainly does the job very well. Hopefully the awarness of current line position (expression?) can be printed withing labels manager in the future. – hilpers Sep 25 '16 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.