The script below works perfectly fine in my computer. But when running the script on another computer, I receive an error:
Error: Algorithm not found
The computer has similar specifications to my own (Windows 7, 64-bit, no admin restrictions). I did the following steps for the computer to match the scripts requirements:
- Installed OSGeo4W
- Copied the
processing
folder fromC:\OSGeo4W64\apps\qgis\python\plugins\processing\
toC:\Users\user_name\.qgis2\python\plugins\
Did I miss something obvious?
import os, sys, glob
from qgis.core import *
from qgis.gui import QgsMapCanvas
from PyQt4.QtGui import *
from os.path import expanduser
home = expanduser("~")
# Set a custom config path
QgsApplication( [], False, home + "\AppData\Local\Temp" )
QgsApplication.setPrefixPath("C:\\OSGeo4W64\\apps\\qgis", True)
QgsApplication.initQgis()
app = QApplication([])
# Folder path of the Results for shapefiles
path_dir = home + "\Desktop\Test\\"
path_res = path_dir + "Results\\"
# Prepare canvas framework from qgis_interface.py
sys.path.append( home + '/Desktop/Test//' )
# Get an iface object
canvas = QgsMapCanvas()
from qgis_interface import QgisInterface
iface = QgisInterface( canvas )
# Prepare processing framework
sys.path.append( home + '/.qgis2/python/plugins' )
# Initialize the Processing plugin passing an iface object
from processing.ProcessingPlugin import ProcessingPlugin
plugin = ProcessingPlugin(iface)
from processing.tools import *
Cellsize = 1000
layerPath = path_dir + "Layer.shp"
extent = QgsVectorLayer( layerPath, '', 'ogr' ).extent()
centerx = (extent.xMinimum() + extent.xMaximum()) / 2
centery = (extent.yMinimum() + extent.yMaximum()) / 2
width = extent.xMaximum() - extent.xMinimum()
height = extent.yMaximum() - extent.yMinimum()
def run():
outputs_1=general.runalg("qgis:creategrid", Cellsize, Cellsize, width, height, centerx, centery, 1, 'EPSG:7405', path_res + "/"+ fname)
run()
QgsApplication.exitQgis()
app.exit()
Aucun commentaire:
Enregistrer un commentaire