Quantcast
Channel: Accessing aggregate functions on another layer in QGIS - Geographic Information Systems Stack Exchange
Viewing all articles
Browse latest Browse all 2

Accessing aggregate functions on another layer in QGIS

$
0
0

I am using QGIS where I have:

  • Layer 1 STREETS : lines each of one representing a street (one line one street), with different fields, with a unique id called "Name" (string)
  • Layer 2 STAKES : points, each representing a stake, with a unique id "UID" (numeric), and different fields, with one of them referring to the street along which it stays. This field is "StreetLink" and refers to the "Name" in layer 1. (a dropdown selection)

I just want to add a calculated field ("NbStakes") in STREET (Layer 1) which counts the number of stakes present along each street.

I found some suggested ways, but did not succeed.

The best I found was with aggregate:

aggregate('Stakes', 'count', 'StreetLink')

I have a number, the same for all streets, and the total sum of stakes. Normal there is no condition linking the correct fields of the 2 layers.

I tried to add a kind of where clause (where the streetlink of table2 is the same as the current Street Name. But it failed. It just gave me zero everywhere

aggregate('Stakes','count','Streetlink',    attribute(@parent, "Streetlink") = "Name"    )

Any suggestion on the correct syntax to use, or another way of doing this?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>