9

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

9

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.

| improve this answer | |
7

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
| improve this answer | |

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.