[QGIS-Developer] Casting a SimpleMarker (renderer) to a SimpleFill one?

Richard Duivenvoorde rdmailings at duif.net
Tue Mar 15 09:29:36 PDT 2022


Hi,

I'm wondering if there is an easy way to put the (mostly colors) of a Point-layer upon another Polygon layer.
(I recall Andreas also wrote about this?)

Usecase: having a layer with a lot of measuring points on it, rule-based styled on value.
Creating a Voronoi-layer from it, and being able to use the (point) rules on that polygons (having the same value)..

I'm able to 'do this' by saving as qml and then hand editing some properties:

class="SimpleMarker"
to
class="SimpleFill"

<symbol name="0" clip_to_extent="1" force_rhr="0" alpha="1" type="marker">
to
<symbol name="0" clip_to_extent="1" force_rhr="0" alpha="1" type="fill">

<layerGeometryType>o</layerGeometryType>
to
<layerGeometryType>2</layerGeometryType>


But I wondered if there is/should be a 'cleaner' way.

Tried [0]:
renderer = layer1.rendererV2()
layer2.setRenderer(renderer)
but that crashes QGIS if you try to open/change a symbol.

Is there a way to do this easier then:
- walk over the rules
- create a QgsSymbolV2.defaultSymbol(layer.geometryType())'s
- copy over some properties...

I'm aware that off course there is a big difference between the point and polygon styles/renderers, but I also think it would be nice to be able to (in QGIS itself) to 'copy' the point style to a polygon style and only take with it whatever 'fits'?

Anybody some info/idea's?

Regards,

Richard Duivenvoorde


[0] https://snorfalorpagus.net/blog/2014/03/04/symbology-of-vector-layers-in-qgis-python-plugins/


More information about the QGIS-Developer mailing list