Difference between revisions of "Explorar o QGIS a partir do Python"
Jump to navigation
Jump to search
(Created page with "QGIS 3 standalone Python script https://gist.github.com/jgrocha/d75d50305e49ba044ff84e96a28f4ed8") |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
| + | https://courses.spatialthoughts.com/pyqgis-in-a-day.html#set-canvas-extent-to-a-layer-extent | ||
| + | |||
QGIS 3 standalone Python script | QGIS 3 standalone Python script | ||
https://gist.github.com/jgrocha/d75d50305e49ba044ff84e96a28f4ed8 | https://gist.github.com/jgrocha/d75d50305e49ba044ff84e96a28f4ed8 | ||
| + | |||
| + | <syntaxhighlight lang="python"> | ||
| + | #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'}) | ||
| + | |||
| + | </syntaxhighlight> | ||
Latest revision as of 14:37, 28 January 2020
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'})