I got this 42 tiles that I'm trying to show each tiles layer name on top of it like a label.
So I can know each tiles name, any Ideas on how to do that?
I have searched the web and found nothing
I got this 42 tiles that I'm trying to show each tiles layer name on top of it like a label.
So I can know each tiles name, any Ideas on how to do that?
I have searched the web and found nothing
You can use PyQGIS. Add all raster layers (and no other layers) to the map and execute code below. It will create centroid points for all rasters with a field holding layer name.
rlyrs = [layer for layer in QgsProject.instance().mapLayers().values()]
#Create point layer
vl = QgsVectorLayer("Point?crs={}&index=yes".format(rlyrs[0].crs().authid()), "myLayer", "memory")
provider = vl.dataProvider()
provider.addAttributes([QgsField("label", QVariant.String)])
vl.updateFields()
#For each raster layer create a point feature from rl extents centroid,
#populate label field with rl name.
for r in rlyrs:
f = QgsFeature()
f.setGeometry(QgsGeometry.fromRect(r.extent()).centroid())
f.setAttributes([r.name()])
provider.addFeature(f)
QgsProject.instance().addMapLayer(vl)