This is a fork of R code and a Shiny web app for doing CTMM analysis of animal movement data from GPS collars. It has been modified to integrate with the NPS Animal Movement database.
It currently presents the animal movement data to the shiny app via CSV extracts from
SQL Server that are converted to R dataframes (rda
). Directly querying the database
was slow and required caching network credentials in the YAML file that the R service
could use for database access, so I had planned to create a scheduled task to refresh
the rda
files on a regular basis.
The CSV files have the following format with the records in timestamp order.
See test.csv
for an example.
id,timestamp,longitude,latitude
LC0802,2008-12-06 00:01:00,-153.7778,60.9401
created with SQL similar to the following:
Select AnimalId as id, fixdate as timestamp, Location.Long as longitude, Location.Lat as latitude
from Locations where projectid = 'PROJECT' order by fixdate
A CSV file was created for each project. The CSV files were converted to rda
files
with the make_data.R
script. The rda
files need to be put in a data
folder in the current working directory when the Run.R
file is executed. Each
file also needs to be shown to the user by adding a reference to each file in
inst/app/server.R.
The web app (actually just an http end point served by the R/Shiny code) was deployed on one of our GIS servers, however it wasn't very stable. It seems like the code was designed to be run in a local mode (single user), and doesn't handle multiple concurrent sessions with different users.
While there are significant advantages of CTMM over other home range anaylsis methods, this project has not progressed past the prototype stage. Resolving the server stability and data refresh issues was put on hold awaiting further direction from the NPS biologists.
To deploy the web app on a local server, see Server_Install.md
This will run the app from the repo dir. These instructions have changed several times as the upstream code has evolved, so you may need to adapt if you encounter errors. The instructions also assume a *nix environment. They will also work in Windows with appropriate adaptations.
-
Use the upstream code to load dependencies
$ cd $repo_dir $ git checkout upstream/master
Start R console and download dependencies.
$ R > install.packages("ctmmweb", repos = c("https://cloud.r-project.org/", "https://ctmm-initiative.github.io/ctmm_repo/")) > quit $
-
Use the NPS fork to run the app
$ git checkout master
Review/edit
run.R
and ensure the path is correct, and there is adata
folder in the cwd. Then$ R --vanilla < run.R &
Or run the local developer version for testing/demonstrations, without internet downloads, etc.
$ cd $repo_dir $ R > shiny:::runApp(appDir=getwd(), port=7893, host="0.0.0.0") ctrl-c # to quit
This is a web app for analyzing animal tracking data, built upon ctmm R package. It's also an R package so you can use some features in your code directly.
- Just run this in R console (More detailed instructions):
if (!require("remotes")) install.packages("remotes")
remotes::install_github("ctmm-initiative/ctmmweb")
ctmmweb::app()
- We also built a windows installer, which will download R installer if needed, install R and package, create shortcut for the app.
Just open https://tiny.cc/ctmmweb (Chrome recommended). This will have some resource limitations compare to run the app locally.
- Check the videos, release History, package reference website
- Suggested citation for the app/package:
X. Dong, C.H. Fleming, M.J. Noonan, and J.M. Calabrese. 2018. ctmmweb: A Shiny web app for the ctmm movement analysis package.
https://github.com/ctmm-initiative/ctmmweb