[R-sig-Geo] Behaviour of pixellate.psp() when spatstat.options(checksegments=F)

Pinaud David pinaud at cebc.cnrs.fr
Mon Nov 28 10:17:24 CET 2011


Dear all,
I want to convert a line segment (trajectory of an animal) to a pixel 
image (a study area), using pixellate.psp() in spatstat package.
For some reasons, some animals moved outside the study area, so I set 
spatstat.options(checksegments=F).
It seems that pixellate.psp() adds values in cells that are not visited 
by the animal, in the border of the grid (see the plot with given example)
I was thinking about alternative solutions (like calculation on a larger 
grid including all the spatial range of the trip), but we faced to 
memory (or running time) problems. We need to do that for >800 trips, on 
a 40000 cells grid... Another way would be to use clip.psp() firt, but I 
need to keep extra information about each segment (eg. ID, time).

Here a reproducible example:
library(spatstat)
spatstat.options(checksegments=F) # to allow segment outside the window
      # the sutdy area :
grida <- owin(c(-0.5, 10.5), c(3.5, 6.5), mask=matrix(TRUE, 
length(seq(3.5, 6.5, by=1)),length(seq(-0.5, 10.5, by=1))),  
xy=list(x=seq(-0.5, 10.5, by=1), y=seq(3.5, 6.5, by=1)))
     # the segment :
d <- psp(x0 = 1:9, x1 = 2:10, y0 = c(1, 1.5, 2, 4, 5, 5.5, 8, 8, 6), y1 
= c(1.5, 2, 4, 5, 5.5, 8, 8, 6, 10), window=grida)
     # segment length per cell
pixd <- pixellate.psp(d, W=grida)
     # plotting, some pixels with value>0 but without segment
plot.im(pixd)
plot(d, add=T)

  sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] trip_1.1-10     sp_0.9-88       spatstat_1.23-4 deldir_0.0-15
[5] mgcv_1.7-6

loaded via a namespace (and not attached):
[1] grid_2.13.1        lattice_0.19-30    Matrix_0.9996875-3 nlme_3.1-101
[5] tools_2.13.1

So, how to pixellate a psp object when some points fall outside the owin 
without using clip.psp?

Many thanks

David


-- 
***************************************************
Dr. David PINAUD
Ingénieur de Recherche "Analyses spatiales"

Centre d'Etudes Biologiques de Chizé - CNRS UPR1934
79360 Villiers-en-Bois, France
poste 485
Tel: +33 (0)5.49.09.35.58
Fax: +33 (0)5.49.09.65.26
http://www.cebc.cnrs.fr/

***************************************************




__________ Information from ESET Mail Security, version of virus signature database 6664 (20111127) __________

The message was checked by ESET Mail Security.
http://www.eset.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pinaud.vcf
Type: text/x-vcard
Size: 324 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20111128/1fb4d616/attachment.vcf>


More information about the R-sig-Geo mailing list