Message posté par : moinards
----------------------------------------
Anyway, I've found a solution. I think the problem was the path of the plugins. I
changed it using sys.path.append. Here is an example of my working code :
-----------------
Code :
import sys
from qgis.core import *
# See
https://gis.stackexchange.com/a/155852/4972 for details about the prefix
QgsApplication.setPrefixPath('/usr', True)
qgs = QgsApplication([], False)
qgs.initQgis()
# Append the path where processing plugin can be found
sys.path.append('/usr/share/qgis/python/plugins/')
from qgis import processing
from processing.core.Processing import Processing
Processing.initialize()
layer1 = QgsVectorLayer('/home/moinards/Documents/bbox.shp', 'layer 1',
'ogr')
layer2 = QgsVectorLayer('/home/moinards/Documents/foussais_polygones.shp',
'layer 2', 'ogr')
results = {}
outputs = {}
feedback = QgsProcessingFeedback()
params = {
'INPUT' : layer1,
'OVERLAY' : layer2,
'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT
}
# See
https://gis.stackexchange.com/a/276979/4972 for a list of algorithms
outputs['Tampon'] = processing.run('qgis:union', params,
feedback=feedback)
params = {
'DISSOLVE': False,
'DISTANCE': 10,
'END_CAP_STYLE': 0, # Rond
'INPUT': outputs['Tampon']['OUTPUT'],
'JOIN_STYLE': 0, # Rond
'MITER_LIMIT': 2,
'OUTPUT': '/home/moinards/Documents/tampon3.shp',
'SEGMENTS': 5,
}
outputs['Tampon_2'] = processing.run('native:buffer', params,
feedback=feedback)
-----------------
----------------------------------------
Le message est situé
https://georezo.net/forum/viewtopic.php?pid=347795#p347795
Pour y répondre : qgis_fr(a)ml.georezo.net ou reply de votre messagerie
Pour vous désabonner connectez-vous sur le forum puis Profil / Abonnement
--
Association GeoRezo - le portail géomatique
https://georezo.net