------------------------------
Message: 15
Date: Tue, 18 Jun 2013 08:47:04 +0200
From: Edzer Pebesma <edzer.pebesma at uni-muenster.de>
To: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] Broken conversion from sp to spatstat ppp
Message-ID: <51C00268.4020208 at uni-muenster.de>
Content-Type: text/plain; charset=windows-1252
David, iirc these conversion methods are in package maptools.
On 06/18/2013 08:40 AM, d.g.rossiter at utwente.nl wrote:
Since upgrading to R 3.0.1 and the latest version of packages sp 1.0.9, gstat 1.0.16, spatstat 1.31-13 the following conversion no longer works:
require(gstat)
data(meuse)
coordinates(meuse) <- ~x + y
meuse.ppp <- as(meuse, "ppp")
Error message:
Error in as(ds, "ppp") :
no method or default for coercing "SpatialPointsDataFrame" to "ppp"
Trying another way:
?
meuse.ppp <- as.ppp(meuse)
Gives a different error message:
Error in as.ppp.default(ds) : Can't interpret X as a point pattern
But I suppose these are at root the same problem.
I can get around this with:
x <- coordinates(meuse)[,1]
y <- coordinates(meuse)[,2]
l1 <- bbox(meuse)[1,1]
l2 <- bbox(meuse)[1,2]
l3 <- bbox(meuse)[2,1]
l4 <- bbox(meuse)[2,2]
win <- owin(xrange=c(l1,l2), yrange=c(l3,l4))
class(win)
window: rectangle = [178605, 181390] x [329714, 333611] units
meuse.ppp <- ppp(x, y, window=win, marks=meuse at data)
plot(meuse.ppp, which.marks="ffreq")
So it seems the conversion routine should be easy to implement or adjust to whatever has changed in R 3.0.
D G Rossiter
Senior University Lecturer
Faculty of Geoinformation and Earth Observation Science
Universiteit Twente.
Enschede (NL)