[R-sig-Geo] spdep and server

Roger Bivand Roger.Bivand at nhh.no
Thu Dec 1 18:41:17 CET 2011


On Thu, 1 Dec 2011, jon.skoien at jrc.ec.europa.eu wrote:

> On 01-Dec-11 17:28, Barry Rowlingson wrote:
>> Its nothing to do with spdep because this is only using the sp package
>> and not spdep.
>> 
>> This is what we call a reproducible example:
>>
>>   library(sp)
>>   d=data.frame(x=rep(1:4,4),y=rep(1:4,rep(4,4)),z=runif(16))
>>   coordinates(d)=~x+y
>>   d.sp=as(d,"SpatialPixels")
>>   d.gr=as(d.sp,"SpatialGridDataFrame")
>> 
>> and that works for me. Cut n paste it and see if it works for you.
>> Then tell us this:
>> 
>>> packageDescription("sp")
>> Package: sp
>> Version: 0.9-88
>> Date: 2011-09-14
>> [etc]
>> 
>
> Then it actually seems to be an sp and/or R version problem.
> Your example works for an old version on my Windows computer (R 2.12.1, 
> sp_0.9-76), but not for the newest version (R 2.14.0, sp_0.9-91). It seems 
> the old version didnt remove the data after the fourth line whereas the new 
> version does.

Yes, current 0.9-91 shows the reported behaviour, so the server is running 
the updated version, the local Windows machine is out of date. We have 
been trying to get the classes to inherit properly - earlier code stepped 
around things that either didn't work then, or we didn't grasp, in S4 
classes. In fact, doing:

d.sp=as(d,"SpatialPixels")
d.gr=as(d.sp,"SpatialGridDataFrame")

should fail, because d.sp has no attribute data, so cannot be coerced to 
SpatialGridDataFrame. This does work:

summary(d)
d.sp=as(d,"SpatialPixelsDataFrame")
d.gr=as(d.sp,"SpatialGridDataFrame")
summary(d.gr)

but Jon's suggestion is equally adeqate.

Roger

>
> Cheers,
> Jon
>
>
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list