Gooong / LeastCostPath

The Least Cost Path Plugin for QGIS
https://plugins.qgis.org/plugins/leastcostpath/
GNU General Public License v3.0
24 stars 12 forks source link

run LeastCostPath standalone #4

Closed juanmanuelrq closed 4 years ago

juanmanuelrq commented 4 years ago

Hi, how can I run LeastCostPath, outside of qgis gui Python interface?

Gooong commented 4 years ago

Hi, you can run it via the python script in QGIS. For example (code from issue #3 ):

vlayer = QgsVectorLayer("D:\\tst\\start.shp", "start", "ogr")
vlayer2 = QgsVectorLayer("D:\\tst\\end.shp", "end", "ogr")
test=processing.run("Cost distance analysis:Least Cost Path", { 'BOOLEAN_OUTPUT_LINEAR_REFERENCE' : False, 'INPUT_COST_RASTER' : 'D:/tst/cost.tif', 'INPUT_END_LAYER' : vlayer2, 'INPUT_RASTER_BAND' : 1, 'INPUT_START_LAYER' : vlayer, 'OUTPUT' : 'memory:' })