[GIS] QGIS SAGA “Kriging” tools doesn’t work

krigingqgisqgis-2qgis-3

I try out different methods of point interpolation for a digital terrain model. For this purpose I tried to run the "ordinary kriging tool" from the SAGA Tools with QGIS 2.18 and QGIS 3.2.

When I run the kriging tool on my points in QGIS 2.18 with default or custom settings I get the error message:

'NoneType' object has no attribute 'crs' See log for more details

This error message also appears when I reproject the point data.

Log message:


            SAGA Version: 2.3.2 (64 bit)

            ____________________________
            library path: [mypath]\saga-ltr\modules\
            library name: statistics_kriging
            library     : Kriging
            tool        : Ordinary Kriging
            author      : O.Conrad (c) 2008
            processors  : 8 [8]
            ____________________________

            Load shapes: [mypath]/points_4326.shp...



            Usage: saga_cmd statistics_kriging 0 [-POINTS <str>] [-FIELD <str>] [-TQUALITY <str>] [-LOG <str>] [-BLOCK <str>] [-DBLOCK <double>] [-VAR_MAXDIST <double>] [-VAR_NCLASSES <num>] [-VAR_NSKIP <num>] [-VAR_MODEL <str>] [-TARGET_DEFINITION <str>] [-TARGET_USER_SIZE <double>] [-TARGET_USER_XMIN <double>] [-TARGET_USER_XMAX <double>] [-TARGET_USER_YMIN <double>] [-TARGET_USER_YMAX <double>] [-TARGET_USER_FITS <str>] [-TARGET_TEMPLATE <str>] [-PREDICTION <str>] [-VARIANCE <str>] [-SEARCH_RANGE <str>] [-SEARCH_RADIUS <double>] [-SEARCH_POINTS_ALL <str>] [-SEARCH_POINTS_MIN <num>] [-SEARCH_POINTS_MAX <num>] [-SEARCH_DIRECTION <str>]
            -POINTS:<str>               Points
            Shapes (input)
            -FIELD:<str>                Attribute
            Table field
            -TQUALITY:<str>             Type of Quality Measure
            Choice
            Available Choices:
            [0] standard deviation
            [1] variance
            Default: 0
            -LOG:<str>                  Logarithmic Transformation
            Boolean
            Default: 0
            -BLOCK:<str>                Block Kriging
            Boolean
            Default: 0
            -DBLOCK:<double>            Block Size
            Floating point
            Minimum: 0.000000
            Default: 100.000000
            -VAR_MAXDIST:<double>       Maximum Distance
            Floating point
            Default: -1.000000
            -VAR_NCLASSES:<num>         Lag Distance Classes
            Integer
            Minimum: 1
            Default: 100
            -VAR_NSKIP:<num>            Skip
            Integer
            Minimum: 1
            Default: 1
            -VAR_MODEL:<str>            Model
            Text
            Default: a + b * x
            -TARGET_DEFINITION:<str>    Target Grid System
            Choice
            Available Choices:
            [0] user defined
            [1] grid or grid system
            Default: 0
            -TARGET_USER_SIZE:<double>  Cellsize
            Floating point
            Minimum: 0.000000
            Default: 1.000000
            -TARGET_USER_XMIN:<double>  Left
            Floating point
            Default: 0.000000
            -TARGET_USER_XMAX:<double>  Right
            Floating point
            Default: 100.000000
            -TARGET_USER_YMIN:<double>  Bottom
            Floating point
            Default: 0.000000
            -TARGET_USER_YMAX:<double>  Top
            Floating point
            Default: 100.000000
            -TARGET_USER_FITS:<str>     Fit
            Choice
            Available Choices:
            [0] nodes
            [1] cells
            Default: 0
            -TARGET_TEMPLATE:<str>      Target System
            Grid (optional input)
            -PREDICTION:<str>           Prediction
            Grid (output)
            -VARIANCE:<str>             Quality Measure
            Grid (optional output)
            -SEARCH_RANGE:<str>         Search Range
            Choice
            Available Choices:
            [0] local
            [1] global
            Default: 0
            -SEARCH_RADIUS:<double>     Maximum Search Distance
            Floating point
            Minimum: 0.000000
            Default: 1000.000000
            -SEARCH_POINTS_ALL:<str>    Number of Points
            Choice
            Available Choices:
            [0] maximum number of nearest points
            [1] all points within search distance
            Default: 0
            -SEARCH_POINTS_MIN:<num>    Minimum
            Integer
            Minimum: 1
            Default: 16
            -SEARCH_POINTS_MAX:<num>    Maximum
            Integer
            Minimum: 1
            Default: 20
            -SEARCH_DIRECTION:<str>     Direction
            Choice
            Available Choices:
            [0] all directions
            [1] quadrants
            Default: 0

            C:\PROGRA~1\QGIS2~1.18\bin>exit
2020-02-14T21:59:58 2   Uncaught error while executing algorithm
            Traceback (most recent call last):
              File "C:/PROGRA~1/QGIS2~1.18/apps/qgis-ltr/./python/plugins\processing\core\GeoAlgorithm.py", line 205, in execute
                self.convertUnsupportedFormats(progress)
              File "C:/PROGRA~1/QGIS2~1.18/apps/qgis-ltr/./python/plugins\processing\core\GeoAlgorithm.py", line 296, in convertUnsupportedFormats
                crsid = layer.crs().authid()
            AttributeError: 'NoneType' object has no attribute 'crs'

After hours of trying I decided to try the same approach with QGIS 3.2, but also here running the tool gives an error:

The following layers were not correctly
generated.

  • C:/Users/[mypath]/processing_18d5097c9c144288b305258c531a35b8/033047b161f94c70a0d0654a3fe16c81/PREDICTION.sdat
  • C:/[mypath]/processing_18d5097c9c144288b305258c531a35b8/2f64571e0e15450394ba5c8caf094e28/VARIANCE.sdat
  • C:/[mypath]/processing_18d5097c9c144288b305258c531a35b8/9fc1718695704c57b4eca4a4beca2bc5/VARIANCE.sdat
  • C:[mypath]/processing_18d5097c9c144288b305258c531a35b8/a84bb60b7694447c83e6bbd32426faf4/PREDICTION.sdat

You
can check the 'Log Messages Panel' in QGIS main window to find more
information about the execution of the algorithm.

Log message:

SAGA Version: 2.3.2 (64 bit)

____________________________
library path: C:\[mypath]\modules\
library name: statistics_kriging
library : Kriging
tool : Ordinary Kriging
author : O.Conrad (c) 2008
processors : 8 [8]
____________________________

Load shapes: [mypath]\Small_subset_poly.shp...



Usage: saga_cmd statistics_kriging 0 [-POINTS <str>] [-FIELD <str>] [-TQUALITY <str>] [-LOG <str>] [-BLOCK <str>] [-DBLOCK <double>] [-VAR_MAXDIST <double>] [-VAR_NCLASSES <num>] [-VAR_NSKIP <num>] [-VAR_MODEL <str>] [-TARGET_DEFINITION <str>] [-TARGET_USER_SIZE <double>] [-TARGET_USER_XMIN <double>] [-TARGET_USER_XMAX <double>] [-TARGET_USER_YMIN <double>] [-TARGET_USER_YMAX <double>] [-TARGET_USER_FITS <str>] [-TARGET_TEMPLATE <str>] [-PREDICTION <str>] [-VARIANCE <str>] [-SEARCH_RANGE <str>] [-SEARCH_RADIUS <double>] [-SEARCH_POINTS_ALL <str>] [-SEARCH_POINTS_MIN <num>] [-SEARCH_POINTS_MAX <num>] [-SEARCH_DIRECTION <str>]
-POINTS:<str> Points
Shapes (input)
-FIELD:<str> Attribute
Table field
-TQUALITY:<str> Type of Quality Measure
Choice
Available Choices:
[0] standard deviation
[1] variance
Default: 0
-LOG:<str> Logarithmic Transformation
Boolean
Default: 0
-BLOCK:<str> Block Kriging
Boolean
Default: 0
-DBLOCK:<double> Block Size
Floating point
Minimum: 0.000000
Default: 100.000000
-VAR_MAXDIST:<double> Maximum Distance
Floating point
Default: -1.000000
-VAR_NCLASSES:<num> Lag Distance Classes
Integer
Minimum: 1
Default: 100
-VAR_NSKIP:<num> Skip
Integer
Minimum: 1
Default: 1
-VAR_MODEL:<str> Model
Text
Default: a + b * x
-TARGET_DEFINITION:<str> Target Grid System
Choice
Available Choices:
[0] user defined
[1] grid or grid system
Default: 0
-TARGET_USER_SIZE:<double> Cellsize
Floating point
Minimum: 0.000000
Default: 1.000000
-TARGET_USER_XMIN:<double> Left
Floating point
Default: 0.000000
-TARGET_USER_XMAX:<double> Right
Floating point
Default: 100.000000
-TARGET_USER_YMIN:<double> Bottom
Floating point
Default: 0.000000
-TARGET_USER_YMAX:<double> Top
Floating point
Default: 100.000000
-TARGET_USER_FITS:<str> Fit
Choice
Available Choices:
[0] nodes
[1] cells
Default: 0
-TARGET_TEMPLATE:<str> Target System
Grid (optional input)
-PREDICTION:<str> Prediction
Grid (output)
-VARIANCE:<str> Quality Measure
Grid (optional output)
-SEARCH_RANGE:<str> Search Range
Choice
Available Choices:
[0] local
[1] global
Default: 0
-SEARCH_RADIUS:<double> Maximum Search Distance
Floating point
Minimum: 0.000000
Default: 1000.000000
-SEARCH_POINTS_ALL:<str> Number of Points
Choice
Available Choices:
[0] maximum number of nearest points
[1] all points within search distance
Default: 0
-SEARCH_POINTS_MIN:<num> Minimum
Integer
Minimum: 1
Default: 16
-SEARCH_POINTS_MAX:<num> Maximum
Integer
Minimum: 1
Default: 20
-SEARCH_DIRECTION:<str> Direction
Choice
Available Choices:
[0] all directions
[1] quadrants
Default: 0

C:\Windows\system32>exit
Execution completed in 9.04 seconds
Results:
{'PREDICTION': 'C:/[mypath]/processing_18d5097c9c144288b305258c531a35b8/a84bb60b7694447c83e6bbd32426faf4/PREDICTION.sdat',
'VARIANCE': 'C:/[mypath]/processing_18d5097c9c144288b305258c531a35b8/9fc1718695704c57b4eca4a4beca2bc5/VARIANCE.sdat'}

Is this problem connected with the SAGA version? How can I solve this problem? Do I have other possibilities to perform kriging with QGIS?

System: Windows 10

Update 1

The origin projection string for the crs (EPSG:32637) is:

PROJCS["WGS_1984_UTM_Zone_37N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",39.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]

I reproject it with the reproject layer tool to EPSG:4326

GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]

Update2

It is very strange behaviour of QGIS. It turns out that the tool doesn't accept the points from my dataset. When I create points maunually in exact the same location it works. It should also work for my data, because I read the data as a textfile (Textfile with X,Y,Z values) and set in that step the coordinate system as Epsg:4326. I saved the data and also restarted the project. The points show up in the right location and can be handled with other tools e.g. IDW Interpolation, but cannot proecessed with the SAGA Kriging tool. Do I have another option to perform Kriging in QGIS? What is with Grass? I saw some tools on the Grass website, but can I implement them in QGIS? And how?

Best Answer

After certain tries I decided to perform all data processing steps in QGIS 2.18 and finally it works. After importing the geometry from the textfile it is also important to export the shapes before doing further processing.

Related Question