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.

(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.)

Cheers, Mike (author of trip)



On Thursday, November 24, 2011, Michael Sumner <mdsum...@gmail.com> wrote:
> I'm not totally sure what you are asking here since as you say and as
> reported by pixellate.psp (from within tripGrid) your tracks do not
> all lie entirely within the grid.
>
>  tgrid <- tripGrid(tr, grid = gt)
> Error: 7 segments do not lie entirely inside the window.
>
> You either need to expand the grid to encompass the data or trim the
> data to lie within the grid - this is not done automatically.
>
> It's also not documented in much detail so if that is the source of
> confusion I apologise.
>
> An easy way to make a grid is to use ?makeGridTopology, which will
> choose defaults based on a lot of varying input data. You can
> initialize the extents by doing
>
>  makeGridTopology(tr)
>
> and you can control the exact options with arguments for cells.dim and so
on.
>
> Cheers, Mike.
>
>
> On Wed, Nov 23, 2011 at 10:22 PM, Pinaud David <pin...@cebc.cnrs.fr>
wrote:
>> 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
>> spatstat.options(checksegments=F)...
>>
>> Any solution?
>>
>> Many thanks
>> David
>>
>> Here a reproducible exemple:
>>
>> library(trip)
>> 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)
>>
>> 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 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)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 6653 (20111123) __________
>>
>> The message was checked by ESET Mail Security.
>> http://www.eset.com
>>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
>
>
>
> --
> Michael Sumner
> Institute for Marine and Antarctic Studies, University of Tasmania
> Hobart, Australia
> e-mail: mdsum...@gmail.com
>

-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@gmail.com

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to