Code Monkey home page Code Monkey logo

recurse's Introduction

Overview of the recurse package

The recurse package can be used to analyze animal trajectory data to look for returns to a previously visited area, i.e. revisitations. These revisits cold be interesting ecologically for a number of reasons. For example, they could be used to identify nesting or denning sites or important resource locations such as water points. Other scenarios include trapline foraging behavior, large-scale movement patterns like migration, and predator-prey interactions.

The recurse package is flexible and supports identifying revisitations of the trajectory itself for single or multiple individuals as well as pre-specifying locations of interest for which to calculate revisitations. In addition to the number of revisits to each location, additional metrics are calculated including the residence time at each location and the time between revisits. Alternatively, one can specify a polygon in which to calaculate revisits and residence time. This could be useful if there was a specific landscape feature where the precise boundary is important, such as a protected area, land use type, or territory.

Example application

Here is a simple example showing how to calculate revisits for a trajectory, using an example data set in the package. For more examples, look at the package vingette or our paper on the package.

Bracis C, Bildstein K and Mueller T (2018). Revisitation analysis uncovers spatio-temporal patterns in animal movement data. Ecography. doi: 10.1111/ecog.03618

library(recurse)
data(martin)
revisits = getRecursions(martin, radius = 2)
plot(revisits, martin, legendPos = c(10, -15))

recurse's People

Contributors

cbracis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

recurse's Issues

Error with getRecursionsInPolygon - if (isNewTrack[j]) { : missing value where TRUE/FALSE needed

Hi,

I am trying to use the getRecursionsInPolygon() function, but I keep getting the following error (and additional warning):

Error in if (isNewTrack[j]) { : missing value where TRUE/FALSE needed
In addition: Warning message:
In diff(as.numeric(trajectory[, idIdx])) : NAs introduced by coercion

Am I failing in providing something that the function needs?

I am providing a data.frame with locations and timestamps, as required:

         x       y           timestamp  id
1 501658.0 4290020 2020-10-18 17:55:00 tag
2 505927.4 4293400 2020-10-18 18:25:00 tag
3 505914.5 4293368 2020-10-18 18:55:00 tag
4 499876.1 4287707 2020-10-18 10:25:00 tag
5 499794.4 4287576 2020-10-18 10:55:00 tag
6 499790.5 4287579 2020-10-18 11:25:00 tag
...

Similarly, I am providing a SpatialPolygons object such as:

An object of class "SpatialPolygons"
Slot "polygons":
[[1]]
An object of class "Polygons"
Slot "Polygons":
[[1]]
An object of class "Polygon"
Slot "labpt":
[1]  503510.9 4294866.7

Slot "area":
[1] 32165780

Slot "hole":
[1] FALSE

Slot "ringDir":
[1] 1

Slot "coords":
         [,1]    [,2]
[1,] 503886.7 4298520
[2,] 507815.9 4294444
[3,] 502844.6 4291035
[4,] 499396.6 4295706
[5,] 503886.7 4298520



Slot "plotOrder":
[1] 1

Slot "labpt":
[1]  503510.9 4294866.7

Slot "ID":
[1] "ID1"

Slot "area":
[1] 32165780



Slot "plotOrder":
[1] 1

Slot "bbox":
        min       max
x  499396.6  507815.9
y 4291034.9 4298519.7

Slot "proj4string":
CRS arguments: +proj=utm +zone=29 +ellps=WGS84 

Thank you in advance!

error in getRecursions "Not compatible with requested type" that can not be debugged

I am getting an error when calling getRecursions using a data.frame. I have tried to debug by looking at the source code but can not determine the error. The data should work in the function. See below.

head(tmp)
x y t id
13045 672819 5536219 2015-03-08 01:02:00 57A.2015
86033 694654 5523683 2015-03-08 03:00:00 57A.2015
30737 695160 5523393 2015-03-08 03:02:00 57A.2015
86035 698207 5521674 2015-03-08 05:02:00 57A.2015
4911 694639 5523749 2015-03-08 06:00:00 57A.2015
5398 694549 5523802 2015-03-08 06:02:00 57A.2015

sapply(tmp, class)
$x
[1] "numeric"

$y
[1] "numeric"

$t
[1] "POSIXlt" "POSIXt"

$id
[1] "character"

recurse::getRecursions(tmp, radius=100)

Error in getRecursionsCpp(x[, 1], x[, 2], x[, 3], x[, 4], x[, 1], x[, :Not compatible with requested type: [type=list; target=double].

dependency on retiring spatial infrastructure packages

You will be aware, for example from:
https://r-spatial.org/r/2022/04/12/evolution.html,
https://r-spatial.org/r/2022/12/14/evolution2.html,
https://r-spatial.org/r/2023/04/10/evolution3.html and
https://rsbivand.github.io/csds_jan23/bivand_csds_ssg_230117.pdf and
perhaps view https://www.youtube.com/watch?v=TlpjIqTPMCA&list=PLzREt6r1NenmWEidssmLm-VO_YmAh4pq9&index=1
that rgdal, rgeos and maptools will be retired this
year, in October 2023.

recurse suggests rgeos but does not pass CMD check when rgeos is absent:
00check.log
Here CMD check was run in a scenario using sp evolution status 2 (substitute use of rgdal with sf for projection/transformation/CRS) and absence of retiring packages from the library path. Possibly the geos package would provide mitigations; see also links from https://r-spatial.org/r/2023/04/10/evolution3.html for further hints. Please fix best by June, latest October 2023.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.