8

I'd like to create some flow maps like the ones shown in Underdark's post: https://anitagraser.com/2016/12/18/details-of-good-flow-maps/

I have a set of location points, say 50, and I'd like to create one "all points to one" map for each point, thus 50 maps in this example. And another set of "one point to all" map for each point, so 50 maps more.

Instead of creating all the extra line layers, I'd like to accomplish this using a combination of Atlas and Geometry generator symbols in QGIS.

However, I'm not finding many examples to see how or if I can do it.

So, is there a site where I can find an exhaustive set of examples of QGIS geometry generator?

This is a clip of the filtered output showing just the top 10 lines from each point. I created all the lines from a csv with the point coordinates using a WKT. Arrows and point symbols are created with the geometry generator. The rest is controlled by Atlas.

enter image description here

8

There is no such site so far. The feature is rather new and usage examples are only starting to emerge now.

For your specific use case, I'd still recommend to create a line layer with all connections. You can then filter this layer using Atlas and don't need to worry about anything else.

  • 1
    Thank you Anita. If you say so, then I better save my time and drop it. I'll go for the line creation then. You know, you could cover this in a next book ;) – Albert Dec 21 '16 at 7:47
6

This is possible using a different 'geometry generator' to the one that you originally intended I suspect, You can avoid having to generate the all connections line layer by using a virtual layer:

Some points:

sample points

Add a virtual layer using the following SQL - the JOIN matches every point to every other, and the line geometry is generated using the Spatialite MakeLine function:

SELECT s.id 'ID1', c.id 'ID2' , MakeLine(s.geometry,c.geometry) 'geometry'
  FROM SamplePoints AS s JOIN SamplePoints AS c 
  WHERE s.id <> c.id

The result:

Points with connecting lines

This virtual table could then be filtered dynamically using the Atlas functionality.

Dynamically generating curved lines would be trickier, but should still be possible. Curving them in a cartographically appropriate way (considering the distribution of the other lines) is probably beyond what can be achieved with virtual layers.

Update:

With a little tinkering and a lot of reference to the Spatialite function list I have generated curved lines:

Points with curved connecting lines

The virtual layer SQL for this is below. Note that all permutations are shown, and reversing the order of the start and end location generates the complementary curve.

SELECT s.id 'ID1', c.id 'ID2' , 
MakeArc(
    X(Project(MakePoint((X(s.geometry)+X(c.geometry))/2,(Y(s.geometry)+Y(c.geometry))/2),distance(s.geometry,c.geometry),Azimuth(s.geometry,c.geometry) - PI()/2)),
    Y(Project(MakePoint((X(s.geometry)+X(c.geometry))/2,(Y(s.geometry)+Y(c.geometry))/2),distance(s.geometry,c.geometry),Azimuth(s.geometry,c.geometry) - PI()/2)),
    distance(s.geometry,c.geometry) * 1.1180339887,
    90 - azimuth(Project(MakePoint((X(s.geometry)+X(c.geometry))/2,(Y(s.geometry)+Y(c.geometry))/2),distance(s.geometry,c.geometry),Azimuth(s.geometry,c.geometry) - PI()/2),s.geometry) * (180/PI()),
    90 - azimuth(Project(MakePoint((X(s.geometry)+X(c.geometry))/2,(Y(s.geometry)+Y(c.geometry))/2),distance(s.geometry,c.geometry),Azimuth(s.geometry,c.geometry) - PI()/2),c.geometry) * (180/PI()),
    27700,
    2) 'geom' /*line:27700*/
  FROM SamplePoints AS s JOIN SamplePoints AS c 
  WHERE s.id <> c.id
  • Thank you Andy, I'll give this a try next time. At the end I created all the lines, it was quite easy using a WKT from a CSV with the coordinates. Curved arrows are much trickier as you say, but the straight lines are enough for my case, since I filter them (I have more than 45k lines) and just show the top 10 flow lines for each point. I'll edit the question and add a screen. In any case, thanx for the tip! – Albert Jan 4 '17 at 7:42
  • That's a really nice way to create curved lines. Nice, Andy!! Nevertheless, the example I added is a bit of an excuse. I find myself in many other examples where I could use this "Geometry generator manual" I'm asking for. I hope @underdark or any of the QGIS team members can find the time to adress this, I think the combination between variables, geometry generator and atlas is one of the strong points in QGIS (Vs ArcGIS) right now but there is not much information about it. – Albert Jan 12 '17 at 12:36

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.