Skip to content

Instantly share code, notes, and snippets.

@gacarrillor
Last active February 28, 2020 17:07
Show Gist options
  • Save gacarrillor/1e9089237f65d18bf05d44aee1f27628 to your computer and use it in GitHub Desktop.
Save gacarrillor/1e9089237f65d18bf05d44aee1f27628 to your computer and use it in GitHub Desktop.
SAGA algorithm (standalone)
import sys
from qgis.core import (
QgsApplication,
QgsProcessingFeedback,
QgsVectorLayer,
QgsProperty
)
# On Linux, you need to prepare the environment with these variables:
# export PYTHONPATH=/docs/dev/qgis/QGIS/build_20190918/output/python/
# export LD_LIBRARY_PATH=/docs/dev/qgis/QGIS/build_20190918/output/lib/
# See https://gis.stackexchange.com/a/155852/4972 for details about the prefix
# Hint: print(QgsApplication.showSettings())
QgsApplication.setPrefixPath('/docs/dev/qgis/QGIS/build_20190918/output', True)
qgs = QgsApplication([], False)
qgs.initQgis()
# Append the path where processing plugin can be found
sys.path.append('/docs/dev/qgis/QGIS/build_20190918/output/python/plugins')
import processing
from processing.core.Processing import Processing
Processing.initialize()
params = {'SHAPES':'/tmp/puntos.shp|layername=puntos',
'FIELD':'PT_NUM_A',
'TARGET_USER_XMIN TARGET_USER_XMAX TARGET_USER_YMIN TARGET_USER_YMAX':None,
'TARGET_USER_SIZE':10,
'TARGET_USER_FITS':0,
'TARGET_OUT_GRID':'TEMPORARY_OUTPUT'}
res = processing.run("saga:triangulation", params)
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment