[R-sig-Geo] silly question on quadratcount in spatstat ?

Adrian Baddeley adrian at maths.uwa.edu.au
Mon Aug 24 05:23:19 CEST 2009


Anna Marburg writes:

> library(spatstat)
> data(humberside)
> Q <- quadratcount(humberside, 5, 5)
> tmp <- attr(Q,"tess")	

The last line is somewhat dangerous as it depends on the undocumented internal structure of a 'quadratcount' object. 
The safe way to convert a quadratcount object to a tessellation is to use 'as.tess'

  tmp <- as.tess(Q)


> til <- tiles(tmp)  #the definition of the quadrats themselves
> m2 <- unlist(lapply(til, function(x) x[[c(4,1,4)]])) #extract the area of each polygon

The last line is very dangerous and will not work in some versions of spatstat. 
The safe way to extract the area of each tile in a tessellation is to use 'area.owin'

     m2 <- unlist(lapply(til, area.owin))


Adrian Baddeley



More information about the R-sig-Geo mailing list