I have a series of LineStringM geometries. The measure value represents slope (or stream gradient) at each point in the geometry. I love QGIS's robust styling options, but I can't find a way to render each measure value along my linestrings. Ideally, I would have blue for slow gradients, and red for very steep gradients.

To help understand what I'm trying to accomplish, let's suppose we've used Linear Referencing to encode the length of the LinestringM thus far into each point's measure value. At the top, you would have 1.0 and at the bottom, you would have 0.0. I've added an image what what I'm hoping to accomplish below. I made this in Paint.NET, so it's just a mock-up. enter image description here direct link to image

How would you go about accomplishing this in QGIS?

  • If your geometry is a LineString and not a MultiLineString I see no obstacle for appropriate classification using a field with a slope value. Can you add some more information - what exactly is your issue? – SS_Rebelious Jan 5 '15 at 8:57
  • 1
    Well, this is a question specific to QGIS, which the title no longer reflects. In QGIS, how do I show the Measure values (inherent in a LinestringM type) visually? Attributes are easily displayed (e.g. the name of the geometry, its ID, etc). However, A LinestringM is made of many points, and each may have a Measure value. I don't see a way to colorize the linestring by its measure value along its path. – standers Jan 5 '15 at 16:36
  • @standers Since you included the PostGIS tag, the question is not necessarily specific to QGIS as you can probably classify your M-values and dump to discrete geometry pieces right from PostGIS. Picking nits, I suppose. – Scro Jan 5 '15 at 17:42
  • @Scro thanks for the heads up. I'll be more discriminating in my tags. That being said, my QGIS instance is reading from my PostGIS DB, and I'm prepared to do whatever transforms in PostGIS that are necessary to visualize my LinestringMs. I hope my tags make more sense now, and I apologize for the confusion. – standers Jan 5 '15 at 18:22
  • To be clear, I was not being critical of the tags (or at all.) Merely pointing out that the tags were more inclusive than the title, and you might get more/better answers by not making it a QGIS-only question. – Scro Jan 5 '15 at 20:36
up vote 9 down vote accepted

One option would be to load the line as one layer and the line vertices (could be a view on the line table) as a second layer which can then be labeled. You can use ST_M() to write the measure value to a view attribute.

Stylingwise, we have to deal with the challenge that there is no gradient line style yet ...

But there are polygon gradient fills. So we can buffer the line and style the buffers. It's a bit of an exercise in data-defined styling though:

enter image description here

  • These would not be interpolated smoothly across the full extent of the linestring - they would be static points that are colored by an attribute from ST_M(). Because I just need some help visualizing the results, this answer seems to be the best so far. I could unleash my inner photoshop skills and find an interesting blend-mode combination between the LinestringM layer and the Points layer. It sounds like there's no immediate way to use Measure values to perform something similar to this image of stream gradients in QGIS (yet). – standers Jan 5 '15 at 21:55
  • @underdark Curious if QGIS ever implemented the line gradient styling that you expected in your blog post: anitagraser.com/2015/01/11/a-line-gradient-style-hack I can't find anything about it. – Jon Apr 27 at 18:55
  • @Jon So far, it hasn't been implemented but there should be easier work-arounds using geometry generators – underdark Apr 28 at 13:13

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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