2

I have two sets of data. A large set of lines with a line_ref field, and a small data-only (no geometry) table with a matching line_ref field (let's say for argument's sake that the data-only table marks recently surveyed sections of pipeline). I'm talking a about a one-to-one relationship on this occasion.

I'm using QGIS 2.8

I can specify a table join, and refer to the joined data from the data-only table in styling the lines.

I can do fancy things with input forms based instead on setting up a relation in the project properties.

What I was wondering was whether I could style the lines based on the relation (rather than specifying a join). I'm prepared to be told that this isn't a sensible thing to do if that's the case.... but I'm thinking ahead to when I start to want to style things where there's a one-to-many relationship. Surely at this point table joins start to get more complex?

  • I guess that you should use the join-based solution. While thinkg on symbolyzing based on one-to-many relations, I wonder that even if you could form a sort of relation ship class; you won't be able to display "many" symbologies for one line; then a glimsp into your data and a better understand of its nature would spread more light on this case – dof1985 Mar 19 '15 at 12:04
  • I'm not currently working on a one-to-many relationship, but I have in the past. I'm thinking that the specifics of my here aren't relevant (this is a common situation). But key to the issue is that the 'many' side does not have any geometry. To be fair I'm beginning to think that this is another side to a question I asked previously ( gis.stackexchange.com/questions/133919/… ) although I didn't initially think it was. Perhaps the answer is: "No this can't be done, use a join or other techniques." – Rostranimin Mar 19 '15 at 12:39
  • Interesting question I also have in my head. Let's say we have a layer A we want to style based on attributes in another related layer B. The relation is 1-N. We could imagine we create a rule which always return one row of layer B for every row of layer A. It could be based on a date attribute and we want the latest for example. This way we don't need to join layers, we just create the relation and style based on it. – Nicolas Boisteault May 31 '18 at 14:23
  • Useful example - interesting thought. – Rostranimin Jun 1 '18 at 17:06
1

In QGIS 2.18 we now have the relation_aggregate function. It returns an aggregate value calculated using all matching child features from a layer relation. You can also use aggregate function which returns an aggregate value calculated using features from another layer. Here is the QEP.

relation_aggregate in QGIS

  • So can we use this function directly in an expression leading to a style? That would be powerful and exciting. – Rostranimin Jun 1 '18 at 17:10

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.