Skip to main content
updated based on comment
Source Link
vinayan
  • 7.3k
  • 3
  • 37
  • 76

the Line,

feature = layer.selectedFeatures() 

returns a list of QgsFeature. You will need to loop over it to process individual selections.

If you only have one feature selected in map, thenlike below.

geomlayer = feature[0]qgis.geometryutils.iface.activeLayer()
for feature in layer.selectedFeatures():
    mbuf = geomfeature.geometry().buffer(50, 2)
    iterFeat = layer.getFeatures()
    for f in iterFeat:
      geom2 = f.geometry()

might work.

the Line,

feature = layer.selectedFeatures() 

returns a list of QgsFeature. You will need to loop over it to process individual selections.

If you only have one feature selected in map, then

geom = feature[0].geometry()
mbuf = geom.buffer(50, 2)

might work.

the Line,

feature = layer.selectedFeatures() 

returns a list of QgsFeature. You will need to loop over it to process individual selections, like below.

layer = qgis.utils.iface.activeLayer()
for feature in layer.selectedFeatures():
    mbuf = feature.geometry().buffer(50, 2)
    iterFeat = layer.getFeatures()
    for f in iterFeat:
      geom2 = f.geometry()
Source Link
vinayan
  • 7.3k
  • 3
  • 37
  • 76

the Line,

feature = layer.selectedFeatures() 

returns a list of QgsFeature. You will need to loop over it to process individual selections.

If you only have one feature selected in map, then

geom = feature[0].geometry()
mbuf = geom.buffer(50, 2)

might work.