[R] Error with adehabitatHR and kernelbb
Michael Sumner
mdsumner at gmail.com
Sat May 18 05:08:37 CEST 2013
I presume it's related to the fact that the X coordinate is duplciated
in the two records, and the grid generated by adehabitatHR is a single
column,
Here's a test:
require(adehabitatHR)
m <- matrix(c(5419574 , 390051, 5419490 , 390051), ncol = 2,
byrow = TRUE)
tt <- as.POSIXct(c("2012-05-30 14:00:00", "2012-05-30 16:00:00"))
id <- c("Ade=5", "Ade-5")
x <- kernelbb(as.ltraj(m, date = tt, id = id, typeII=TRUE), sig1 =
4.5766, sig2 = 5, grid = 1000)
This degenerate Y dimension affects downstream methods (like image),
and I'd say this is worth reporting to the package author as an issue:
dim(x[[1]])
[1] 1000 1
dim(x[[2]])
[1] 1000 1
The clue comes from points2grid in sp:
Warning messages:
1: In points2grid(points, tolerance, round) :
cell size from constant coordinate 2 possibly taken from other coordinate
You could override the auto-generated grid by passing in your own,
probably something you will want anyway so that your collection share
the same extent and resolution. See ?kernelbb, the "grid" argument can
be a Spatial object rather than a pixel size.
I would really wonder about what is the point in generating summaries
from single line-segments, but that is off-topic I guess.
Cheers, Mike.
On Sat, May 18, 2013 at 4:47 AM, Rémi Lesmerises
<remilesmerises at yahoo.ca> wrote:
> There was some mistakes in my previous sending. The following are correct.
>
> This is the problematic data, especially the line 43, but when I removed that line, it bugs at line 62 and so on.
>
>
> sig1 time id UTMnorthin UTMeasting
> 40 4.5766 2012.05.30 08:00:00 Ade-5 5419576 390052
> 41 4.5766 2012.05.30 10:00:00 Ade-5 5419581 390058
> 42 4.5766 2012.05.30 12:00:00 Ade-5 5419560 390045
> 43 4.5766 2012.05.30 14:00:00 Ade-5 5419574 390051
> 44 4.5766 2012.05.30 16:00:00 Ade-5 5419490 390051
> 45 4.5766 2012.05.30 18:00:00 Ade-5 5419435 390293
> 46 4.5766 2012.05.30 20:00:00 Ade-5 5419661 390876
> 47 4.5766 2012.05.30 22:00:00 Ade-5 5419934 390673
> 48 4.5766 2012.05.31 02:00:00 Ade-5 5420636 389777
> 49 4.5766 2012.06.05 02:00:00 Ade-7 5419275 391206
> 50 4.5766 2012.06.05 04:00:00 Ade-7 5419276 391202
>
> This is a data frame so before the loop (see commands in the previous mail below), I transform with the following commands:
>
>>coordinates(fece)<-~UTMeasting+UTMnorthin
>>loc at data$time <- as.POSIXct(strptime(as.character(loc at data$time),"%Y.%m.%d %H:%M:%S"))
>
>
> Rémi Lesmerises, biol. M.Sc.,
> PH.D candidate
> Université du Québec à Rimouski
>
> ________________________________
> De : David Winsemius <dwinsemius at comcast.net>
> À : Rémi Lesmerises <remilesmerises at yahoo.ca>
> Cc : "r-help at r-project.org" <r-help at r-project.org>
> Envoyé le : vendredi 17 mai 2013 13h53
> Objet : Re: [R] Error with adehabitatHR and kernelbb
>
>
>
> On May 17, 2013, at 7:44 AM, Rémi Lesmerises wrote:
>
>> Dear all,
>>
>> I'm trying to get a Brownian bridge kernel (kernelbb) for each combination of two consecutive animal locations (see commands below) and put them, with a loop, inside a list. It works well at the beginning but after 42 runs, it appears the following warning :
>>
>>
>>> Error in seq.default(yli[1], yli[2], by = diff(xg[1:2])) :
>>> invalid (to - from)/by in seq(.)
>>
>> I looked at the coordinates, at the id, at the time of the run 43 and it's all good...
>>
>> I looked on the net and it happened to only one person and there was no answer to his post.
>
> I wonder if that posting (like yours) had no data on which to display the problem or to test potential solutions? I would think you would want to post any setup objects and then data for items 40-45.
>
>>
>> Someone could help me?
>>
>> ## commands
>>
>> BBtraj <- list()
>> for (i in 1:(nrow(loc at data)-1)) {
>> BBtraj[[i]] <- kernelbb(as.ltraj(loc at coords[i:(i+1),], date=loc at data$time[i:(i+1)], id = as.character(loc at data$id[i:(i+1)]),
>> typeII = TRUE), sig1=as.numeric(as.character(loc at data$sig1[i])), sig2= 5, grid = 1000)
>> }
>>
> --
>
>
> David Winsemius
> Alameda, CA, USA
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Michael Sumner
Hobart, Australia
e-mail: mdsumner at gmail.com
More information about the R-help
mailing list