[R-sig-Geo] saga grid_gridding problem

Tomislav Hengl hengl at spatial-analyst.net
Mon Apr 5 15:04:56 CEST 2010


Quoting Francisco Alonso Sarria <alonsarp at um.es>:

>
> Hi:
>
> I'm begining to work with rsaga and saga compiled on ubuntu linux and I
> have  problems when I want to generate a grid from a point file (by the
> way is the example  of section 6.3.1 in Hengl's book "A practical guide
> to geoestatistical mapping")
>
> I have a seg. fault when I try to take the grid properties from a sgrd
> file and if I try to define the grid in command line it doesn't work
> properly. In detail:
>
>
> $ saga_cmd libgrid_gridding.so 0 -INPUT AS_ICP40 -GRID AS_ICP40_5
> -LINE_TYPE 0 -FIELD 0 -TARGET 1 -GRID_GRID geomap_sapa.sgrd
>
> _____________________________________________
>   #####   ##   #####    ##
>  ###     ###  ##       ###
>   ###   # ## ##  #### # ##
>    ### ##### ##    # #####
> ##### #   ##  ##### #   ##
>
> SAGA CMD 2.0.4
> _____________________________________________
> library path:	/usr/local/lib/saga/
> library name:	libgrid_gridding.so
> module name :	Shapes to Grid
> author      :	O.Conrad (c) 2003
> _____________________________________________
> go...
>
> Load shapes: AS_ICP40...
> 100%
> ready
>
> okay
>
>
>
>
> Parameters
>
>
>
>
> Grid: [not set]
> Shapes: AS_ICP40
> Attribute: AS_ICP40
> Method for Lines: thin
> Preferred Target Grid Type: Floating Point (4 byte)
> Target Grid: grid
>
> Fallo de segmentación   (spanish for seg.fault ;-)
>
> On the other hand:
>
> $ saga_cmd libgrid_gridding.so 0 -INPUT AS_ICP40 -GRID AS_ICP40_5
> -LINE_TYPE 0 -FIELD 1 -TARGET 1 -USER_YMAX 3217500 -USER_YMIN 262500
> -USER_XMIN -2402500 -USER_XMAX 2292500 -USER_SIZE 5000
>
> ____________________________________________
>   #####   ##   #####    ##
>  ###     ###  ##       ###
>   ###   # ## ##  #### # ##
>    ### ##### ##    # #####
> ##### #   ##  ##### #   ##
>
> SAGA CMD 2.0.4
> _____________________________________________
> library path:	/usr/local/lib/saga/
> library name:	libgrid_gridding.so
> module name :	Shapes to Grid
> author      :	O.Conrad (c) 2003
> _____________________________________________
> go...
>
> Load shapes: AS_ICP40...
> 100%
> ready
>
> okay
>
>
>
>
> Parameters
>
>
>
>
> Grid: [not set]
> Shapes: AS_ICP40
> Attribute: AS_ICP40
> Method for Lines: thin
> Preferred Target Grid Type: Floating Point (4 byte)
> Target Grid: user defined
>
> 100%
> Save grid: AS_ICP40_5...
> 100%
> ready
>
> okay
>
>
> all ok but:
>
> $ cat AS_ICP40_5.sgrd
>
> NAME	= AS_ICP40 [AS_ICP40]
> DESCRIPTION	=
> UNIT	=
> DATAFILE_OFFSET	= 0
> DATAFORMAT	= FLOAT
> BYTEORDER_BIG	= FALSE
> POSITION_XMIN	= -2402500.0000000000
> POSITION_YMIN	= 262500.0000000000
> CELLCOUNT_X	= 203
> CELLCOUNT_Y	= 101
> CELLSIZE	= 5000.0000000000
> Z_FACTOR	= 1.000000
> NODATA_VALUE	= -99999.000000
> TOPTOBOTTOM	= FALSE
>
> As you can see CELLCOUNT_* don't fit with the USER_* parameters passed
> and the resulting map has no data because there are no points in that
> particular subgrid. If I change CELLSIZE to 50000 the CELLCOUNT_* are
> the same but now all the points are in the grid and I have a map.
>
> Is it a bug in the linux version of SAGA?

First of all, I do not send operations to SAGA command line directly,  
but use the RSAGA package instead (it is then easier to combine R  
objects and SAGA operations). As far as I know, RSAGA should work on  
Linux machines also  
[https://stat.ethz.ch/pipermail/r-sig-geo/2009-July/006075.html]. So  
the point to raster operation you mention would look like this:

----------------------------------
> rsaga.geoprocessor(lib="grid_gridding", module=0,  
> param=list(GRID="PB_ICP40.sgrd", INPUT="PB_ICP40.shp", FIELD=0, 
> LINE_TYPE=0, USER_CELL_SIZE=5000, USER_X_EXTENT_MIN=-2402500,  
> USER_X_EXTENT_MAX=2292500, USER_Y_EXTENT_MIN=262500,  
> USER_Y_EXTENT_MAX=3217500))

SAGA CMD 2.0.4

Load table: D:\BOOK\NGS\saga.srs...

failed
library path:   C:/Progra~1/saga_vc/modules
library name:   grid_gridding
module name :   Shapes to Grid
author      :   (c) 2003 by O.Conrad

Load shapes: PB_ICP40.shp...
ready

ready

Parameters

Grid: [not set]
Shapes: PB_ICP40
Attribute: PB_ICP40
Target Dimensions: User defined
Method for Lines: thin

Save grid: PB_ICP40.sgrd...
ready

> GDALinfo("PB_ICP40.sdat")
rows        592
columns     940
bands       1
origin.x        -2405000
origin.y        260000
res.x       5000
res.y       5000
oblique.x   0
oblique.y   0
driver      SAGA
projection  NA
file        PB_ICP40.sdat
apparent band summary:
    GDType        Bmin       Bmax
1 Float32 -4294967295 4294967295
--------------------------------------------------------------------

which means that the operation was successful. Note that I point to  
field "0", i.e. first field in the table and not field "1" as in you  
example. Of course, the point data needs to be in the same coordinate  
system, otherwise the resulting map will be empty.

I doubt it that there is a bug in the SAGA operation. SAGA for Linux  
is just compiled in a different way, but the code (C++) is the same.  
Please try to closely follow the R script  
(http://spatial-analyst.net/book/NGS.R) and then let me know if you  
still experience problems. Otherwise, you should report the problem to  
the SAGA GIS user's forum  
[http://sourceforge.net/projects/saga-gis/forums/forum/790705].


T. Hengl
http://home.medewerker.uva.nl/t.hengl/



>
> Thanks in advance for any help
>
> Paco
>
> =========================
> Francisco Alonso Sarría
> Departamento de Geografía
> Universidad de Murcia
> =========================
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list