Code Monkey home page Code Monkey logo

Comments (1)

16EAGLE avatar 16EAGLE commented on August 24, 2024

Here is the solution I've send you as reply to your mail:

library(moveVis)
library(move)
library(magrittr)
library(lubridate)

pdfhrecenttracks <- read.csv("pdfhrecenttracks.csv", stringsAsFactors = F)
pdfhrecenttracks$time <- as.POSIXct(pdfhrecenttracks$time, format="%Y-%m-%d %H:%M:%S", tz="UTC")
             
# align movement
m.move <- move(x=pdfhrecenttracks$location.long, y=pdfhrecenttracks$location.lat, time=pdfhrecenttracks$time,
               data=pdfhrecenttracks, proj=CRS("+proj=longlat +ellps=WGS84 + towgs84=0,0,0"), animal=pdfhrecenttracks$trackId, sensor=pdfhrecenttracks$sensor)

# remove those tracks that consist of only one location, these cannot be aligned, minimum of 2 locations is required for interpolation
m.move <- m.move[[sapply(split(m.move), length) > 1]]

# choose a resolution not to far from your sampling intervalls, e.g. 1 day, since the median of all time lags is nearly 24 hours
# For example:
res <- m.move %>% 
  timeLag(units = "secs") %>% 
  sapply(function(x) (median(x)/60)/60) %>% 
  median() %>% 
  round()

m <- align_move(m = m.move, res = res, unit = "hours")

#Get unique colors -----------
n <- n.indiv(m)
color = grDevices::colors()[grep('gr(a|e)y', grDevices::colors(), invert = T)]
unique.colors <- sample(color, n)
pie(rep(1,n), col=unique.colors)

frames <- frames_spatial(m, path_colours = unique.colors, map_service = "osm", map_type = "watercolor", alpha = 0.5,
                         path_legend = F) %>%
  add_labels(x = "Longitude", y = "Latitude") %>% # add some customizations, such as axis labels
  add_northarrow() %>% 
  add_scalebar() %>% 
  add_timestamps(m, type = "label") %>% 
  add_progress()

animate_frames(frames, out_file = "test.gif", overwrite = T)

Pleas reopen, if anything is unclear.

from movevis.

Related Issues (20)

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.