The file bivariate_legend.py has a missing import.
Open file /Users/judithheher/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/BivariateLegend/bivariate_legend.py in any editor.
Add from qgis.core import Qgis to the import section.
Restart QGIS and retry. The plugin will run seamlessly.
There is no problem in your code or no bug with QGIS. createRenderer method is deprecated since v3.10. Therefore, there may be incompatibility between the method and later versions of QGIS. I recommend you use the constructor.
Instead of categorizing the data by intensity, you can categorized it by a concatenation of intensity and affected_p
The expression would be similar to "intensity" || ' - ' || sum("affected_p","intensity")
The example below use the average instead of the sum:
You may choose:
to use GDAL using ogrmerge.py like here but with setting a destination target not a file but your database compare to this example https://twitter.com/ThomasG77/status/1362118505819176966 See ogrmerge doc
looping with bash doing something like below (not exact as it depends from your own table structure)
psql -c "CREATE TABLE ...
As I understand it, the only way to update geometry on the go (using this reshapeGeometry method at least) is to access the layer's data provider:
layer = iface.activeLayer()
provider = layer.dataProvider()
line = QgsLineString([QgsPoint(1, 1), QgsPoint(2, 2)])
for feat in layer.selectedFeatures():
geom = feat.geometry()
From a little search and experimentation:
from qgis.utils import iface
from qgis.core import QgsProject
from PyQt5.QtCore import QObject, Qt
from PyQt5.QtWidgets import QAction
self.root = QgsProject.instance().layerTreeRoot()
self.current = self.root.findLayer(iface.activeLayer().id())
To adapt the code you are using to categorize based on the expression suggested by @JGH, you actually need to create the list of unique values and QgsRendererCategory list based on the expression.
Please try the code below, adapted (and 'Pythonicized') from the logic in the addCategories() method of QgsCategorizedSymbolRendererWidget class which starts at ...
In the end creating an instance of QgsVectorLayerExporter and passing it the desired geometry type helped.
con_string = """dbname='gis' host='localhost' port='25432' user='qgis' password='qgis'
key='id' table="public"."my_layer_new" (geom)"""
exporter = QgsVectorLayerExporter(con_string, 'postgres', fields=...