Explorar o QGIS a partir do Python

From Geomaster, Lda
Jump to navigation Jump to search

https://courses.spatialthoughts.com/pyqgis-in-a-day.html#set-canvas-extent-to-a-layer-extent

QGIS 3 standalone Python script

https://gist.github.com/jgrocha/d75d50305e49ba044ff84e96a28f4ed8

#import re
#for alg in QgsApplication.processingRegistry().algorithms():
#    if re.match('.*Clip.*', alg.displayName()):
#        # gdal:cliprasterbymasklayer
#        print(alg.id(), "->", alg.displayName())

# processing.algorithmHelp("gdal:cliprasterbymasklayer")

base_layer = iface.activeLayer()
# features = layer.getFeatures()

# 'selectedFeaturesOnly': False
# QgsProcessingFeatureSourceDefinition(base_layer.id(), False)

processing.run("native:buffer", 
            {'INPUT': QgsProcessingFeatureSourceDefinition(base_layer.id(), False),
              'DISTANCE': 100.0,
              'SEGMENTS': 10,
              'DISSOLVE': True,
              'END_CAP_STYLE': 0,
              'JOIN_STYLE': 0,
              'MITER_LIMIT': 10,
              'OUTPUT': '/tmp/buffers.shp'})