1

I want to build a little script, which generates a NaturalNeighbor grid based on a point Shapefile. The script runs within my PyDev environment without any error messages, but no outputfile is created. When I set the output to None (meaning generating a temporary file) the folder in /tmp/processing/ is created but is empty.

I am running on Ubuntu 12.04 in a PyDev environment.

here my sourcecode

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, os
from osgeo import ogr

sys.path.append('/usr/share/qgis/python/plugins')
sys.path.append('/usr/share/qgis/python')

qgisprefix = '/usr'
os.environ['PATH'] = qgisprefix+'/bin'
os.environ['LD_LIBRARY_PATH'] = qgisprefix+'/lib'
sys.path.insert(0, qgisprefix+'/share/qgis/python')
sys.path.insert(1, qgisprefix+'/share/qgis/python/plugins')
os.environ['QGIS_DEBUG'] = '-1'

from qgis.core import *
from qgis.gui import *


QgsApplication.setPrefixPath(qgisprefix, True)
QgsApplication.initQgis()
app = QgsApplication([], True)

from PyQt4 import QtCore, QtGui
import processing

class DummyInterface(object):
    def __init__(self):
        self.destCrs = None
    def __getattr__(self, *args, **kwargs):
        def dummy(*args, **kwargs):
            return DummyInterface()
        return dummy
    def __iter__(self):
        return self
    def next(self):
        raise StopIteration
    def layers(self):
        return QgsMapLayerRegistry.instance().mapLayers().values()
iface = DummyInterface()

processing.getObjectFromUri
plugin = processing.classFactory(iface)

area = "in/proj_area/proj_area.shp"
shapes = "out/tiepoints_process.shp"

drv = ogr.GetDriverByName("ESRI Shapefile")
ds_proj_area = drv.Open(area) 
if ds_proj_area is None:
    print "Area of Interest could not be opened."
    sys.exit(1)   

proj_area_layer = ds_proj_area.GetLayer()
proj_area_extent = proj_area_layer.GetExtent()
extent = ', '.join(map(str, proj_area_extent))

inputfn = QgsVectorLayer(shapes, "1", "ogr")
outputfn = "out/test11.tif"

processing.runalg("saga:naturalneighbour", inputfn, "z-diff", 0, False, extent, 1, outputfn)

And here the part of the processing logfile in /home/.qgis2/processing/processing.log

ALGORITHM|Thu Sep 18 2014 10:42:21|processing.runalg("saga:naturalneighbour","out/tiepoints_process.shp","z-diff",0,False,"459463.935231, 462847.074318, 5614519.53746, 5617679.91841",1,"out/test11.tif")
INFO|Thu Sep 18 2014 10:42:21|SAGA execution commands|libgrid_gridding "Natural Neighbour" -SHAPES "out/tiepoints_process.shp" -FIELD "z-diff" -TARGET 0 -USER_XMIN 459464.435231 -USER_XMAX 462846.574318 -USER_YMIN 5614520.03746 -USER_YMAX 5617679.41841 -USER_SIZE 1 -USER_GRID "out/test11.tif.sgrd"|libio_gdal 1 -GRIDS "out/test11.tif.sgrd" -FORMAT 1 -TYPE 0 -FILE "out/test11.tif"
INFO|Thu Sep 18 2014 10:42:21|SAGA execution console output|Error: library|_____________________________________________||#####   ##   #####    ##|###     ###  ##       ###|###   # ## ##  #### # ##|### ##### ##    # #####|##### #   ##  ##### #   ##|_____________________________________________|||63 loaded module libraries (631 modules):|- io_esri_e00|- io_pgsql|- table_tools|- ihacres|- ta_preprocessor|- grid_visualisation|- grid_tools|- ta_channels|- io_gdal|- pj_proj4|- geostatistics_kriging|- sim_hydrology|- io_grid_grib2|- shapes_transect|- ta_morphometry|- grid_filter|- io_grid_image|- shapes_points|- geostatistics_regression|- table_calculus|- contrib_a_perego|- pointcloud_tools|- imagery_classification|- pj_georeference|- io_shapes_dxf|- ta_compound|- imagery_svm|- imagery_tools|- ta_hydrology|- imagery_segmentation|- garden_webservices|- grid_gridding|- recreations_fractals|- climate_tools|- lectures_introduction|- sim_ecosystems_hugget|- io_gps|- sim_cellular_automata|- ta_profiles|- sim_erosion|- docs_html|- pointcloud_viewer|- io_odbc|- tin_viewer|- io_shapes|- garden_3d_viewer|- grid_calculus|- shapes_polygons|- tin_tools|- shapes_grid|- shapes_tools|- geostatistics_points|- io_grid|- ta_lighting|- io_table|- grid_analysis|- imagery_rga|- docs_pdf|- grid_calculus_bsl|- grid_spline|- geostatistics_grid|- recreations_games|- shapes_lines||type -h or --help for further information||Error: library|_____________________________________________||#####   ##   #####    ##|###     ###  ##       ###|###   # ## ##  #### # ##|### ##### ##    # #####|##### #   ##  ##### #   ##|_____________________________________________|||63 loaded module libraries (631 modules):|- io_esri_e00|- io_pgsql|- table_tools|- ihacres|- ta_preprocessor|- grid_visualisation|- grid_tools|- ta_channels|- io_gdal|- pj_proj4|- geostatistics_kriging|- sim_hydrology|- io_grid_grib2|- shapes_transect|- ta_morphometry|- grid_filter|- io_grid_image|- shapes_points|- geostatistics_regression|- table_calculus|- contrib_a_perego|- pointcloud_tools|- imagery_classification|- pj_georeference|- io_shapes_dxf|- ta_compound|- imagery_svm|- imagery_tools|- ta_hydrology|- imagery_segmentation|- garden_webservices|- grid_gridding|- recreations_fractals|- climate_tools|- lectures_introduction|- sim_ecosystems_hugget|- io_gps|- sim_cellular_automata|- ta_profiles|- sim_erosion|- docs_html|- pointcloud_viewer|- io_odbc|- tin_viewer|- io_shapes|- garden_3d_viewer|- grid_calculus|- shapes_polygons|- tin_tools|- shapes_grid|- shapes_tools|- geostatistics_points|- io_grid|- ta_lighting|- io_table|- grid_analysis|- imagery_rga|- docs_pdf|- grid_calculus_bsl|- grid_spline|- geostatistics_grid|- recreations_games|- shapes_lines||type -h or --help for further information|

Am I doing something wrong here with the outputdataset or is there a error in the installation?

  • what version of saga are you using? – johanvdw Sep 18 '14 at 9:03
  • 2.1.1 and in QGIS the 2.0.8 Syntax option is disabled. And I am using QGIS 2.4 – andehhh Sep 18 '14 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.