[Qgis-user] (re)colloring overlapping parts of multipolygons

Charles Dixon-Paver charles at kartoza.com
Sun Jun 20 04:40:16 PDT 2021


Basically my expression was using an aggregate to capture that intersection
count produced by the model and set the feature color based on that. The
idea was that if you could find a way to dynamically produce individual
features for overlapping areas you may be able to do everything using
expressions, but I have no idea how you would go about accomplishing that.

After a brief bit of fiddling it seems even using the native "split by
lines" or union tools result in topology that isn't very clean, so the
aggregate doesn't work very well and that model that was linked to from
github produces a much cleaner output.

The aggregate expression takes the input layer and gets a count of
intersecting features. It doesn't really need anything other than the
feature geometry. It could be extended to check intersection count with
another layer though.

It may be somewhat useful if you are 100% restricted to not performing any
preprocessing, but I think it would actually make a map more confusing in
most instances.

I've linked to a screenshot[1] of my color based expression for reference.
The label value in the attached image is expression based:

aggregate(@layer,aggregate:='count',expression:=1,filter:=intersects($geometry,geometry(@parent)))

>From that you should see that you could feasibly obtain the same
"count" value as the model using the field calculator, however it relies on
clean input geometries that have already been split up.

In any event, this is of limited use for your particular use case, but as
close as I could get using only dynamically generated parameters. Maybe one
day we will have the ability to split or crack features with the geometry
generators and this would have more utility.

[1] https://imgur.com/a/ZBfInpS

On Sun, 20 Jun 2021 at 09:33, Richard Duivenvoorde <rdmailings at duif.net>
wrote:

> On 6/20/21 1:22 AM, Charles Dixon-Paver wrote:
>
> > Basically my suggestion would be to use an expression like
> color_hsv(aggregate(@layer,aggregate:='count',expression:="id",filter:=intersects($geometry,geometry(@parent)))*40,100,100)
>
> Thanks Charles! Looks very interesting, but I'm not able to use it yet:
> what does it need as input layer(s)/features?
> Does it need a count column? This is only setting the color of overlapping
> features yes?
>
> Meanwhile I found
> https://github.com/kgjenkins/qgis-count-polygon-overlap
>
> Which happily counts the overlaps, after using my earlier expression to
> create the different polygons, so I can easily color them according to that
> count. See screenshot.
>
> I'm still very interested in your coloring expression though :-)
>
> Regards,
>
> Richard Duivenvoorde
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210620/b5bad04f/attachment.html>


More information about the Qgis-user mailing list