[STATSGRASS] Trend surface analysis issue - sending results back to GRASS

Jarosław Jasiewicz jarekj at amu.edu.pl
Fri Sep 29 06:30:36 EDT 2006


Carlos "Guâno" Grohmann napisał(a):
> Just another doubt? what the surface with degree=0 mean? it look like
> a membrane that passes through all the points..
>
> carlos
>
>
Hi all

I thing I found method which still allow to use ls.surface and trmat 
with spgrass6

1) first: prepare grass region as you know it must be quadratic (same nw 
nd se value)
2) we need two files: raster nad vector points in the same region
3) put the both to R with readRAST6 and readVECT6. The grid (raster 
obiect will be our dummy obiect to avoid creating new grid topology. 
Save raster as "dummy" //it's name not type

4) Convert vector point obiect into "simple" data frame use:
newdata=data.frame(sppoint) - where sppoint SpatialDataFrame imported 
form grass
newdata1=data.frame(x=smdata$coords.x1, y=smdata$coords.x2, z=smdata$z) 
- to have x,y, z data frame. I assume z  is argument for which trend is 
created. x and y remains as it was in grass

5) do surf.ls and trmat or any you want

If uou do trmat yu MUST use:
surface=trmat(trend, G$w, G$e, G$s, G$n, G$rows-1) where G  is obeict 
returned by gmeta6() look on this: G$rows-1

6) obiect surface is a matrix n x n we must transpose it:
matrix=surface$z[,nrow(surface$z):1] //I will not

7) we must contaminate matrix to vector:
vmatrix=c(matrix)

nad know we going back to our "dummy" raster
replace:
dummy$grassraster=vmatrix  - where grassraster is the name of the raster 
from grass

now we have  SpatialGridData frame which can be simply put back to grass:
writeRAST6(dummy, "name_in_grass", zcol="vmatrix", NODATA=-9999.99, 
ignore.stderr=TRUE)

that all. It works

If you don't want to convert spatial*dataframe to dataframe you can use 
postgreSQL to transport data from grass to R, but you will need raster 
"dummy" obiect

regards
Jarek





More information about the grass-stats mailing list