[R-sig-Geo] question about wireframe

Edzer Pebesma edzer.pebesma at uni-muenster.de
Thu Feb 21 20:52:58 CET 2013



On 02/21/2013 06:03 PM, Hodgess, Erin wrote:
> Hello!
>
> I have a krigeST object:
>
>> str(kr1)
> Formal class 'STFDF' [package "spacetime"] with 4 slots
>    ..@ data   :'data.frame':     8250 obs. of  1 variable:
>    .. ..$ var1.pred: num [1:8250] 95 95.1 95.3 95.4 95.6 ...
>    ..@ sp     :Formal class 'SpatialPoints' [package "sp"] with 3 slots
>    .. .. ..@ coords     : num [1:825, 1:2] -108 -108 -107 -106 -106 ...
>    .. .. .. ..- attr(*, "dimnames")=List of 2
>    .. .. .. .. ..$ : NULL
>    .. .. .. .. ..$ : chr [1:2] "lon" "lat"
>    .. .. ..@ bbox       : num [1:2, 1:2] -108 24 -92 36
>    .. .. .. ..- attr(*, "dimnames")=List of 2
>    .. .. .. .. ..$ : chr [1:2] "lon" "lat"
>    .. .. .. .. ..$ : chr [1:2] "min" "max"
>    .. .. ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
>    .. .. .. .. ..@ projargs: chr " +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
>    ..@ time   :An ‘xts’ object on 2001-01-01/2010-01-01 containing:
>    Data: int [1:10, 1] 1 2 3 4 5 6 7 8 9 10
>   - attr(*, "dimnames")=List of 2
>    ..$ : NULL
>    ..$ : chr "timeIndex"
>    Indexed by objects of class: [Date] TZ: UTC
>    xts Attributes:
>   NULL
>    ..@ endTime: POSIXct[1:10], format: "2002-01-01" "2003-01-01" ...
>
>
> I would like to draw a wireframe, but I keep getting the following:
>
>> str(pred.grd)
> Formal class 'STF' [package "spacetime"] with 3 slots
>    ..@ sp     :Formal class 'SpatialPoints' [package "sp"] with 3 slots
>    .. .. ..@ coords     : num [1:825, 1:2] -108 -108 -107 -106 -106 ...
>    .. .. .. ..- attr(*, "dimnames")=List of 2
>    .. .. .. .. ..$ : NULL
>    .. .. .. .. ..$ : chr [1:2] "lon" "lat"
>    .. .. ..@ bbox       : num [1:2, 1:2] -108 24 -92 36
>    .. .. .. ..- attr(*, "dimnames")=List of 2
>    .. .. .. .. ..$ : chr [1:2] "lon" "lat"
>    .. .. .. .. ..$ : chr [1:2] "min" "max"
>    .. .. ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
>    .. .. .. .. ..@ projargs: chr " +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
>    ..@ time   :An ‘xts’ object on 2001-01-01/2010-01-01 containing:
>    Data: int [1:10, 1] 1 2 3 4 5 6 7 8 9 10
>   - attr(*, "dimnames")=List of 2
>    ..$ : NULL
>    ..$ : chr "timeIndex"
>    Indexed by objects of class: [Date] TZ: UTC
>    xts Attributes:
>   NULL
>    ..@ endTime: POSIXct[1:10], format: "2002-01-01" "2003-01-01" ...
>> wireframe(pred.grd at coords[,1],pred.grd at coords[,2],pred.grd at time,data=kr1$var1.pred)
> Error in wireframe(pred.grd at coords[, 1], pred.grd at coords[, 2], pred.grd at time,  :
>    no slot of name "coords" for this object of class "STF"
>>

the error message is pretty clear; showClass("STF") would have told you 
where to look, as does your output above: assuming kr1 and pred.grd 
refer to the same geometry, you should have used pred.grd at sp@coords and 
index(pred.grd at time).

Simpler would be to use as(kr1, "data.frame") and specify your wireframe 
from there, using the formula var1.pred~lon+lat .

I don't understand what you expect lattice::wireframe to do when you 
pass it four vectors.

>
>
> Thanks,
> Erin
> PS this is with the latest version of gstat and spacetime (2/19)
>
>
> 	[[alternative HTML version deleted]]
>
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list