Well, I managed to get the residuals of the trend-surface analysis in a Spatial data Frame. <br>
<br>
Here's what I did:<br>
<br>
<br>
library(spgrass6) ; library(spatial);<br>
srtm <- getSites6sp("toposrtm");<br>
coords<-coordinates(srtm);<br>
class(srtm);<br>
G <- gmeta6();<br>
grd <- GridTopology(cellcentre.offset=c(G$west+(G$ewres/2),
G$south+(G$nsres/2)), cellsize=c(G$ewres, G$nsres), cells.dim=c(G$cols,
G$rows));<br>
mask_SG <- SpatialGridDataFrame(grd, data=list(k=rep(1, G$cols*G$rows)), proj4string=CRS(G$proj4));<br>
class(mask_SG);<br>
<br>
trend <- surf.ls(1, x=coords[,1], y=coords[,2], z=srtm$cat);<br>
resid1<-residuals(trend);<br>
resid2<-as.data.frame(resid1);<br>
resid.trend<-SpatialPointsDataFrame(coords,resid2);<br>
resid.img <- SpatialGridDataFrame(grd, resid.trend);<br>
<br>
<br>
<br>
Now I'll start playing with variograms and kriggind.<br>
<br>
Thanks all!<br>
<br>
Carlos<br>
<br><br><div><span class="gmail_quote">On 2/21/06, <b class="gmail_sendername">Roger Bivand</b> <<a href="mailto:Roger.Bivand@nhh.no">Roger.Bivand@nhh.no</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Carlos,<br><br>On Tue, 21 Feb 2006, Carlos "Guâno" Grohmann wrote:<br><br>> Hello list<br>><br>> I've away from R a while, and now I'm struggling with it...<br>> I read Bivand's artile in GRASS-News3, but I dindn't understant exactly how
<br>> the data is stored in R.<br>><br><br>Please see a note in R News in November 2005 by Edzer Pebesma and me.<br><br>> If I want to make a trend-surface analysis with surf.ls(), I need the x,y<br>> and z coordinates of each point (or pixel), but I don't know how to get
<br>> these values<br><br>The object returned by getSites6sp() is a SpatialPointsDataFrame. You can<br>get the coordinates by saying:<br><br>pointlayer <- getSites6sp("mypoints")<br>coords <- coordinates(pointlayer)
<br><br>and assuming z is called z:<br><br>myTSA <- surf.ls(2, x=coords[,1], y=coords[,2], z=pointlayer$z)<br><br>but you can also do TSA straight away in gstat:<br><br>myTSA_with_gstat <- gstat(id="tr2", formula = z ~ 1, data = pointlayer,
<br> degree=2)<br><br>(the most recent gstat just takes the location coordinates from the<br>SpatialPointsDataFrame object.)<br><br>There was a thread about this recently, I think copied to:<br><br><a href="http://grass.gdf-hannover.de/twiki/pub/GRASS/WebHome/krigingusingRGRASS6.txt">
http://grass.gdf-hannover.de/twiki/pub/GRASS/WebHome/krigingusingRGRASS6.txt</a><br><br>where a grid is created from the GRASS region settings to predict to.<br><br>Hope this helps,<br><br>Roger<br><br>><br>> the whole idea is to make TSA, then variogram fitting in the residuals, then
<br>> krigging (maybe with gstat or geoR, still haven't decided)<br>><br>> thanks<br>><br>> --<br>> +-----------------------------------------------------------+<br>> Carlos Henrique Grohmann - Guano
<br>> Geologist M.Sc - Doctorate Student at IGc-USP - Brazil<br>> Linux User #89721 - carlos dot grohmann at gmail dot com<br>> +-----------------------------------------------------------+<br>> _________________
<br>> "Good morning, doctors. I have taken the liberty of removing Windows 95 from<br>> my hard drive."<br>> --The winning entry in a "What were HAL's first words" contest judged by<br>> 2001: A SPACE ODYSSEY creator Arthur C. Clarke
<br>><br><br>--<br>Roger Bivand<br>Economic Geography Section, Department of Economics, Norwegian School of<br>Economics and Business Administration, Helleveien 30, N-5045 Bergen,<br>Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
<br>e-mail: <a href="mailto:Roger.Bivand@nhh.no">Roger.Bivand@nhh.no</a><br><br></blockquote></div><br><br clear="all"><br>-- <br>+-----------------------------------------------------------+<br> Carlos
Henrique Grohmann - Guano <br> Geologist M.Sc - Doctorate Student at IGc-USP - Brazil<br>Linux User #89721 - carlos dot grohmann at gmail dot com<br>+-----------------------------------------------------------+<br>_________________
<br>"Good morning, doctors. I have taken the liberty of removing Windows 95 from my hard drive."<br>--The winning entry in a "What were HAL's first words" contest judged by 2001: A SPACE ODYSSEY creator Arthur C. Clarke