The cluster renderer is a relatively new feature of QGIS. As you've discovered, it only has two variables, cluster_color
and cluster_size
. It lacks variables like @currentcluster or similar, that would allow you to build an expression that refers to all of the points in a single cluster.
There is a recently-opened feature request for exactly this feature. I recommend watching that request for further developments.
In the meantime, your only option would be to generate your own point clusters.
One way is to generate a hexagonal grid, and symbolize it based on the average wind speed of the wind point it intersects.
Note: Unlike the cluster renderer, this method does not change cluster size based on zoom level. You would have to create a separate grid for every zoom level, and use scale-based visibility on each grid layer.
For example, my wind points layer is called 'wind' and the wind speed field is called 'speed'. Using the functions from the refFunctions plugin, I used this expression to calculate the average wind speed within each grid cell:
intersecting_geom_sum('wind','speed' )/ intersecting_geom_count( 'wind')
Add average wind speed and average wind direction as fields to the grid layer.
In case not every grid cell has a wind speed point in it, use this expression to define layer visibility:
"avg_wind_speed" > 0 and "avg_wind_speed" is not null
Set up centroid fill symbology with two levels of marker:
- One level is simple points.
- The other level is a vector field. Use the fields "avg_wind_speed" and "avg_wind_direction" to control length and angle of the vector field.
In case not every grid cell has a wind speed point in it, use this expression to define layer visibility:
"avg_wind_speed" > 0 and "avg_wind_speed" is not null
This gives a slightly random appearance to the point layout, although you can still see that the points are vertically aligned. If that's a problem, you could add a random data-defined offset to the centroid fill. Eg, define the x-coordinate as $x + rand(0,10)
and likewise for the y-coordinate. Choose values for the rand() function that are appropriate to your layer units and scale.