I'm trying to label a shapefile with coordinates from attribute table with pyqgis.
I've been messing around with labeling shapefiles with python, I can do most things that I need, but the main setting still eludes me. How do I set data defined coordinates with python from attribute table (label_x, label_y).
Below is just a sample code for triggering labels but it does not have anything in it to trigger labels from coordinates.
myLayer = QgsProject.instance().mapLayersByName('test_poligon') settings = QgsPalLayerSettings() settings.fieldName = "Fid" settings.placement = 3 settings.enabled = True settings = QgsVectorLayerSimpleLabeling(settings) myLayer.setLabelsEnabled(True) myLayer.setLabeling(settings) myLayer.triggerRepaint()