[R-sig-Geo] Problem with tripGrid when some segments lie outside the study area

Pinaud David pinaud at cebc.cnrs.fr
Wed Nov 23 12:22:58 CET 2011

Dear all,

I'm calculating time spent per cell over a grid (study area) with the 
package "trip", for satellite-tracked seabirds.
Some birds bred outside the area of interest (Kerguelen Plateau, to 
design marine protected areas), so their trips didn't lie entirely in 
the grid. In this case, it seems that time is added in some cells that 
are not visited by the bird (tipically in the border of the grid).
This problem seems coming from pixellate(), and because I need to set 

Any solution?

Many thanks

Here a reproducible exemple:

Le chargement a nécessité le package : sp
Le chargement a nécessité le package : spatstat
Le chargement a nécessité le package : mgcv
This is mgcv 1.7-6. For overview type 'help("mgcv-package")'.
Le chargement a nécessité le package : deldir
deldir 0.0-15

Please note: The process for determining duplicated points
has changed from that used in version 0.0-9 (and previously).

spatstat 1.23-4
Type ‘help(spatstat)’ for an overview of spatstat
‘latest.news()’ for news on latest version
‘licence.polygons()’ for licence information on polygon calculations

spatstat.options(checksegments=F) # to allow segment outside the window

# a trip with some parts outside the study area :
d <- data.frame(x = 1:10, y = c(1, 1.5, 2, 4, 5, 5.5, 8, 8, 6, 10), tms 
= Sys.time() + seq(10,100, 10), id = rep(1, 10))
coordinates(d) <- ~x+y
tr <- trip(d, c("tms", "id"))

# the sutdy area :
gridaa <- expand.grid(Long=seq(-0.5, 10.5, by=1), Lat=seq(3.5, 6.5, by=1))
coordinates(gridaa) <- ~ Long + Lat
gridded(gridaa) <- T
fullgrid(gridaa) <- T
gt <- getGridTopology(gridaa)

# time spent per cell
tgrid <- tripGrid(tr, grid = gt)

image(tgrid, axes=T)
points(coordinates(tr), t="l", col="blue")
points(gridaa, pch="+")
text(x= midpoints.psp(as.psp(tr)), col="green", pos=3, labels=1:9)

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

[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 spatstat_1.23-4 deldir_0.0-15 mgcv_1.7-6
[5] sp_0.9-88

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

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)
Fax: +33 (0)


__________ Information from ESET Mail Security, version of virus signature database 6653 (20111123) __________

The message was checked by ESET Mail Security.

-------------- 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/20111123/823d71f1/attachment.vcf>

More information about the R-sig-Geo mailing list