[R-sig-Geo] Broken conversion from sp to spatstat ppp

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Jun 18 08:47:04 CEST 2013


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)
> [1] "owin"
>> 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)
> 
> _______________________________________________
> 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
83 33081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de



More information about the R-sig-Geo mailing list