<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Michael,<br>
Yes, this error occured before, that's why I set firstly
spatstat.options(checksegments=F) to avoid that. But in this case
(checksegments=F), it seems that pixellate.psp() behaves "strangely"
and adds time in cells that are not visited by the bird, in the
border of the grid (see the plot with my example)<br>
I think about this alternative solution (calculation on a larger
grid), but we faced to memory (or running time) problems. We need to
do that for >800 trips, on a 40000 cells grid... So I was
thinking about clipping first the trip according to the grid limits,
then running tripGrid(), but this problem (with pixellate.psp()?)
occured.<br>
Do you have an idea how we can do that?<br>
<br>
Otherwise, your package is very usefull!<br>
<br>
Many thanks<br>
<br>
David<br>
<br>
Le 23/11/2011 22:26, Michael Sumner a écrit :
<blockquote
cite="mid:CAAcGz989ML+Rj075GL2L94zYVL5AyADQ_Oab2fVoe33-9SzL3A@mail.gmail.com"
type="cite">I should have added that probably the best way to trim
the result is to just trim the grid built on the full data, then
there is no messy problem with line intersections or spatial vs
time based subsetting. That is I think closest to your request.<br>
<br>
(This kind of "time spent" estimate is also very simplistic and
dependent on the cell size chosen and assumptions about "straight
line" movement. That is another thing the doc should say more
clearly I think.)<br>
<br>
Cheers, Mike (author of trip)<br>
<br>
<br>
<br>
On Thursday, November 24, 2011, Michael Sumner <<a
moz-do-not-send="true" href="mailto:mdsumner@gmail.com">mdsumner@gmail.com</a>>
wrote:<br>
> I'm not totally sure what you are asking here since as you
say and as<br>
> reported by pixellate.psp (from within tripGrid) your tracks
do not<br>
> all lie entirely within the grid.<br>
><br>
> tgrid <- tripGrid(tr, grid = gt)<br>
> Error: 7 segments do not lie entirely inside the window.<br>
><br>
> You either need to expand the grid to encompass the data or
trim the<br>
> data to lie within the grid - this is not done automatically.<br>
><br>
> It's also not documented in much detail so if that is the
source of<br>
> confusion I apologise.<br>
><br>
> An easy way to make a grid is to use ?makeGridTopology, which
will<br>
> choose defaults based on a lot of varying input data. You can<br>
> initialize the extents by doing<br>
><br>
> makeGridTopology(tr)<br>
><br>
> and you can control the exact options with arguments for
cells.dim and so on.<br>
><br>
> Cheers, Mike.<br>
><br>
><br>
> On Wed, Nov 23, 2011 at 10:22 PM, Pinaud David <<a
moz-do-not-send="true" href="mailto:pinaud@cebc.cnrs.fr">pinaud@cebc.cnrs.fr</a>>
wrote:<br>
>> Dear all,<br>
>><br>
>> I'm calculating time spent per cell over a grid (study
area) with the<br>
>> package "trip", for satellite-tracked seabirds.<br>
>> Some birds bred outside the area of interest (Kerguelen
Plateau, to design<br>
>> marine protected areas), so their trips didn't lie
entirely in the grid. In<br>
>> this case, it seems that time is added in some cells that
are not visited by<br>
>> the bird (tipically in the border of the grid).<br>
>> This problem seems coming from pixellate(), and because I
need to set<br>
>> spatstat.options(checksegments=F)...<br>
>><br>
>> Any solution?<br>
>><br>
>> Many thanks<br>
>> David<br>
>><br>
>> Here a reproducible exemple:<br>
>><br>
>> library(trip)<br>
>> Le chargement a nécessité le package : sp<br>
>> Le chargement a nécessité le package : spatstat<br>
>> Le chargement a nécessité le package : mgcv<br>
>> This is mgcv 1.7-6. For overview type
'help("mgcv-package")'.<br>
>> Le chargement a nécessité le package : deldir<br>
>> deldir 0.0-15<br>
>><br>
>> Please note: The process for determining duplicated
points<br>
>> has changed from that used in version 0.0-9 (and
previously).<br>
>><br>
>> spatstat 1.23-4<br>
>> Type ‘help(spatstat)’ for an overview of spatstat<br>
>> ‘latest.news()’ for news on latest version<br>
>> ‘licence.polygons()’ for licence information on polygon
calculations<br>
>><br>
>> spatstat.options(checksegments=F) # to allow segment
outside the window<br>
>><br>
>> # a trip with some parts outside the study area :<br>
>> d <- data.frame(x = 1:10, y = c(1, 1.5, 2, 4, 5, 5.5,
8, 8, 6, 10), tms =<br>
>> Sys.time() + seq(10,100, 10), id = rep(1, 10))<br>
>> coordinates(d) <- ~x+y<br>
>> tr <- trip(d, c("tms", "id"))<br>
>><br>
>> # the sutdy area :<br>
>> gridaa <- expand.grid(Long=seq(-0.5, 10.5, by=1),
Lat=seq(3.5, 6.5, by=1))<br>
>> coordinates(gridaa) <- ~ Long + Lat<br>
>> gridded(gridaa) <- T<br>
>> fullgrid(gridaa) <- T<br>
>> gt <- getGridTopology(gridaa)<br>
>><br>
>> # time spent per cell<br>
>> tgrid <- tripGrid(tr, grid = gt)<br>
>><br>
>> image(tgrid, axes=T)<br>
>> points(coordinates(tr), t="l", col="blue")<br>
>> points(gridaa, pch="+")<br>
>> text(x= midpoints.psp(as.psp(tr)), col="green", pos=3,
labels=1:9)<br>
>><br>
>> sessionInfo()<br>
>> R version 2.13.1 (2011-07-08)<br>
>> Platform: i386-pc-mingw32/i386 (32-bit)<br>
>><br>
>> locale:<br>
>> [1] LC_COLLATE=French_France.1252
LC_CTYPE=French_France.1252<br>
>> [3] LC_MONETARY=French_France.1252 LC_NUMERIC=C<br>
>> [5] LC_TIME=French_France.1252<br>
>><br>
>> attached base packages:<br>
>> [1] stats graphics grDevices utils datasets methods base<br>
>><br>
>> other attached packages:<br>
>> [1] trip_1.1-10 spatstat_1.23-4 deldir_0.0-15 mgcv_1.7-6<br>
>> [5] sp_0.9-88<br>
>><br>
>> loaded via a namespace (and not attached):<br>
>> [1] grid_2.13.1 lattice_0.19-30 Matrix_0.9996875-3
nlme_3.1-101<br>
>><br>
>> --<br>
>> ***************************************************<br>
>> Dr. David PINAUD<br>
>> Ingénieur de Recherche "Analyses spatiales"<br>
>><br>
>> Centre d'Etudes Biologiques de Chizé - CNRS UPR1934<br>
>> 79360 Villiers-en-Bois, France<br>
>> poste 485<br>
>> Tel: +33 (0)5.49.09.35.58<br>
>> Fax: +33 (0)5.49.09.65.26<br>
>> <a moz-do-not-send="true"
href="http://www.cebc.cnrs.fr/">http://www.cebc.cnrs.fr/</a><br>
>><br>
>> ***************************************************<br>
>><br>
>><br>
>><br>
>><br>
>> __________ Information from ESET Mail Security, version
of virus signature<br>
>> database 6653 (20111123) __________<br>
>><br>
>> The message was checked by ESET Mail Security.<br>
>> <a moz-do-not-send="true" href="http://www.eset.com">http://www.eset.com</a><br>
>><br>
>><br>
>> _______________________________________________<br>
>> R-sig-Geo mailing list<br>
>> <a moz-do-not-send="true"
href="mailto:R-sig-Geo@r-project.org">R-sig-Geo@r-project.org</a><br>
>> <a moz-do-not-send="true"
href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br>
>><br>
>><br>
><br>
><br>
><br>
> --<br>
> Michael Sumner<br>
> Institute for Marine and Antarctic Studies, University of
Tasmania<br>
> Hobart, Australia<br>
> e-mail: <a moz-do-not-send="true"
href="mailto:mdsumner@gmail.com">mdsumner@gmail.com</a><br>
><br>
<br>
-- <br>
Michael Sumner<br>
Institute for Marine and Antarctic Studies, University of Tasmania<br>
Hobart, Australia<br>
e-mail: <a moz-do-not-send="true"
href="mailto:mdsumner@gmail.com">mdsumner@gmail.com</a><br>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
***************************************************
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
<a class="moz-txt-link-freetext" href="http://www.cebc.cnrs.fr/">http://www.cebc.cnrs.fr/</a>
***************************************************</pre>
<br>
<br>
__________ Information from ESET Mail Security, version of virus signature database 6654 (20111123) __________<br>
<br>
The message was checked by ESET Mail Security.<br>
<A HREF="http://www.eset.com">http://www.eset.com</A><br>
</body>
</html>