as.ppp

0th

Percentile

coercion from sp objects to spatstat objects

Keywords
spatial
Aliases
  • as.ppp
  • as.ppp.Spatial
  • as.owin.SpatialGridDataFrame
  • as.owin.SpatialPixelsDataFrame
  • as.owin.SpatialPolygons
  • coerce,SpatialGridDataFrame,owin-method
  • coerce,SpatialPixelsDataFrame,owin-method
  • coerce,SpatialPolygons,owin-method
  • as.ppp.SpatialGridDataFrame
  • as.ppp.SpatialPoints
  • as.ppp.SpatialPointsDataFrame
  • coerce,SpatialPoints,ppp-method
  • coerce,SpatialPointsDataFrame,ppp-method
Examples
library(spatstat)
data(meuse)
coordinates(meuse) = ~x+y
zn1 <- as(meuse["zinc"], "ppp")
zn1
plot(zn1)
as(as(meuse, "SpatialPoints"), "ppp")
data(meuse.grid)
gridded(meuse.grid) = ~x+y
mg_owin <- as(meuse.grid, "owin")
zn1a <- ppp(x=zn1$x, y=zn1$y, marks=zn1$marks, window=mg_owin)
zn1a
plot(zn1a)
# as.owin(meuse.grid)
# --- will only work if as.owin is method...
as(as(meuse.grid["ffreq"], "SpatialPixelsDataFrame"), "owin")
ho_sp <- SpatialPolygons(list(Polygons(list(Polygon(cbind(c(0,1,1,0,0),
  c(0,0,1,1,0))), Polygon(cbind(c(0.6,0.4,0.4,0.6,0.6), 
  c(0.2,0.2,0.4,0.4,0.2)), hole=TRUE)), ID="ho")))
plot(ho_sp, col="red", pbg="pink")
ho <- as(ho_sp, "owin")
plot(ho)
pp <- runifpoint(500, win=ho)
plot(pp)
ho_orig <- owin(poly=list(list(x=c(0,1,1,0), y=c(0,0,1,1)),
  list(x=c(0.6,0.4,0.4,0.6), y=c(0.2,0.2,0.4,0.4))))
identical(ho, ho_orig)
Documentation reproduced from package maptools, version 0.6-3, License: GPL version 2 or later (R and interface code), MIT (shapelib code)

Community examples

Looks like there are no examples yet.