as.ppp

0th

Percentile

coercion between sp objects and spatstat objects

S4-style as() coercion works from objects of S4 sp classes to spatstat S3 classes, but not the reverse. Coercion to sp classes uses direct function calls.

Keywords
spatial
Usage
as.SpatialPoints.ppp(from)
as.SpatialPointsDataFrame.ppp(from)
as.SpatialGridDataFrame.ppp(from)
as.SpatialGridDataFrame.im(from)
as.psp.Line(from, ..., window=NULL, marks=NULL, fatal)
as.psp.Lines(from, ..., window=NULL, marks=NULL, fatal)
as.psp.SpatialLines(from, ..., window=NULL, marks=NULL, fatal)
as.psp.SpatialLinesDataFrame(from, ..., window=NULL, marks=NULL, fatal)
Arguments
from
object to coerce from
...
other arguments to be passed through
window
window as defined in the spatstat package
marks
marks as defined in the spatstat package
fatal
formal coercion argument
Note

When coercing a SpatialPolygons object to an owin object, full topology checking is enabled by default. To avoid checking, set spatstat.options(checkpolygons=FALSE) (from spatstat (1.14-6)). To perform the checking later, owinpolycheck(W, verbose=TRUE).

Aliases
  • as.owin.SpatialGridDataFrame
  • as.owin.SpatialPixelsDataFrame
  • as.owin.SpatialPolygons
  • as.im.SpatialGridDataFrame
  • coerce,SpatialGridDataFrame,owin-method
  • coerce,SpatialPixelsDataFrame,owin-method
  • coerce,SpatialPolygons,owin-method
  • coerce,SpatialGridDataFrame,im-method
  • as.ppp.SpatialGridDataFrame
  • as.ppp.SpatialPoints
  • as.ppp.SpatialPointsDataFrame
  • coerce,SpatialPoints,ppp-method
  • coerce,SpatialPointsDataFrame,ppp-method
  • as.psp.Line
  • as.psp.Lines
  • as.psp.SpatialLines
  • as.psp.SpatialLinesDataFrame
  • coerce,Line,psp-method
  • coerce,Lines,psp-method
  • coerce,SpatialLines,psp-method
  • coerce,SpatialLinesDataFrame,psp-method
  • coerce,im,SpatialGridDataFrame-method
  • coerce,ppp,SpatialGridDataFrame-method
  • coerce,ppp,SpatialPointsDataFrame-method
  • coerce,ppp,SpatialPoints-method
  • as.SpatialPointsDataFrame.ppp
  • as.SpatialGridDataFrame.ppp
  • as.SpatialPoints.ppp
  • as.SpatialGridDataFrame.im
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)
rev_ppp_SP <- as.SpatialPoints.ppp(zn1a)
summary(rev_ppp_SP)
rev_ppp_SPDF <- as.SpatialPointsDataFrame.ppp(zn1a)
summary(rev_ppp_SPDF)
rev_ppp_SGDF <- as.SpatialGridDataFrame.ppp(zn1a)
summary(rev_ppp_SGDF)
data(meuse.riv)
mr <- Line(meuse.riv)
mr_psp <- as(mr, "psp")
mr_psp
plot(mr_psp)
# as.owin(meuse.grid)
# --- will only work if as.owin is method...
mg_owin <- as(as(meuse.grid["ffreq"], "SpatialPixelsDataFrame"), "owin")
mg_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)
mg_dist <- meuse.grid["dist"]
fullgrid(mg_dist) <- TRUE
image(mg_dist, axes=TRUE)
mg_im <- as(mg_dist, "im")
plot(mg_im)
mg2 <- as.SpatialGridDataFrame.im(mg_im)
image(mg2, axes=TRUE)
Documentation reproduced from package maptools, version 0.7-20, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.