Skip to main content
added 28 characters in body; edited tags; edited title
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

How to change Changing marker shape to ArrowHead? using PyQGIS

With the code below I can add a marker to the symbology of a line type layer. But by default, this marker is a circle.

layerName = 'rede_bombas'
vLayer = QgsProject.instance().mapLayersByName(layerName)[0]

ggsl = QgsGeometryGeneratorSymbolLayer.create({})
ggsl.setSymbolType(QgsSymbol.Marker)
ggsl.setGeometryExpression("centroid($geometry)")
ggsl.setColor(QColor('Blue'))
symbol = vLayer.renderer().symbols(QgsRenderContext())[0]
symbol.insertSymbolLayer(1, ggsl)
vLayer.triggerRepaint()
layerName = 'rede_bombas'
vLayer = QgsProject.instance().mapLayersByName(layerName)[0]

ggsl = QgsGeometryGeneratorSymbolLayer.create({})
ggsl.setSymbolType(QgsSymbol.Marker)
ggsl.setGeometryExpression("centroid($geometry)")
ggsl.setColor(QColor('Blue'))
symbol = vLayer.renderer().symbols(QgsRenderContext())[0]
symbol.insertSymbolLayer(1, ggsl)
vLayer.triggerRepaint()

How do I change the marker shape to ArrowHead?

Is it possible to adjust the marker rotation according to the line rotation?

enter image description here

How to change marker shape to ArrowHead?

With the code below I can add a marker to the symbology of a line type layer. But by default this marker is a circle.

layerName = 'rede_bombas'
vLayer = QgsProject.instance().mapLayersByName(layerName)[0]

ggsl = QgsGeometryGeneratorSymbolLayer.create({})
ggsl.setSymbolType(QgsSymbol.Marker)
ggsl.setGeometryExpression("centroid($geometry)")
ggsl.setColor(QColor('Blue'))
symbol = vLayer.renderer().symbols(QgsRenderContext())[0]
symbol.insertSymbolLayer(1, ggsl)
vLayer.triggerRepaint()

How do I change the marker shape to ArrowHead?

Is it possible to adjust the marker rotation according to the line rotation?

enter image description here

Changing marker shape to ArrowHead using PyQGIS

With the code below I can add a marker to the symbology of a line type layer. But by default, this marker is a circle.

layerName = 'rede_bombas'
vLayer = QgsProject.instance().mapLayersByName(layerName)[0]

ggsl = QgsGeometryGeneratorSymbolLayer.create({})
ggsl.setSymbolType(QgsSymbol.Marker)
ggsl.setGeometryExpression("centroid($geometry)")
ggsl.setColor(QColor('Blue'))
symbol = vLayer.renderer().symbols(QgsRenderContext())[0]
symbol.insertSymbolLayer(1, ggsl)
vLayer.triggerRepaint()

How do I change the marker shape to ArrowHead?

Is it possible to adjust the marker rotation according to the line rotation?

enter image description here

Source Link

How to change marker shape to ArrowHead?

With the code below I can add a marker to the symbology of a line type layer. But by default this marker is a circle.

layerName = 'rede_bombas'
vLayer = QgsProject.instance().mapLayersByName(layerName)[0]

ggsl = QgsGeometryGeneratorSymbolLayer.create({})
ggsl.setSymbolType(QgsSymbol.Marker)
ggsl.setGeometryExpression("centroid($geometry)")
ggsl.setColor(QColor('Blue'))
symbol = vLayer.renderer().symbols(QgsRenderContext())[0]
symbol.insertSymbolLayer(1, ggsl)
vLayer.triggerRepaint()

How do I change the marker shape to ArrowHead?

Is it possible to adjust the marker rotation according to the line rotation?

enter image description here