Skip to content
Prev 7657 / 29559 Next

Prevent minor discrepancy in pixel resolution using Spatstat

On Wed, 17 Feb 2010, Tyler Dean Rudolph wrote:

            
I think that you are seeing the impact of your input window not being 
exactly divisible by your eps in as.mask() and then getting nr and nc that 
do not partition the x and y ranges into discrete 25m blocks, because of 
ceiling().

             if (!is.null(eps)) {
                 nr <- ceiling(diff(w$yrange)/eps)
                 nc <- ceiling(diff(w$xrange)/eps)
             }

Browse[2]> nr
[1] 15
Browse[2]> nc
[1] 12

With:

subwin<-owin(xrange=c(-100, 110+2.7) + sort(c(temp$x, temp$X2)),
  yrange=c(-100, 90+18.6) + sort(c(temp$y, temp$Y2)))

you get something like what you want, with a lot of fiddling. Have you 
considered not setting eps, using spatstat.options("npixel") to set nr and 
nc, and tailoring the window to suit 25m (yrange == eps*nr, etc.). If you 
know the xrange, yrange of the raster you want to compare with, maybe use 
that as the source for the window, spatstat.options("npixel") to feed 
through nr and nc, then you could fix eps indirectly?

Hope this helps,

Roger