#' Plot position data as processed by merge_pos_file()
#'
#' @param data a *.pos data logger / tracker file location
#' @param vi a tag number (if set this defaults to unknown)
#' @param window_size number of trailing or leading days over which to
#' integrate remote sensing (vegetation index) data
#' @return plots data processed by merge_pos_file()
#'
#' @keywords ancillary data, remote sensing, google earth engine
#' @export
#' @examples
#' \dontrun{
#' map_pos_data(data = ...)
#' }
map_pos_data = function(data = NULL,
vi = "evi",
window_size = 60){
# read the data if necessary
if(!is.data.frame(data)){
if(file.exists(data)){
data = readRDS(data)
}else{
stop("file is not present...")
}
}
# split out the components
raw_modis_data = data[[1]]
summary_data = data[[2]]
ggplot() +
geom_tile(data = raw_modis_data, aes(x = date, y = site, fill = vi)) +
scale_fill_viridis() +
geom_line(data = unique(location),
aes(x = date + window_size,
y = sample), col = "white") +
geom_line(data = unique(location),
aes(x = date,
y = sample), col = "red") +
geom_line(data = unique(location),
aes(x = date - window_size,
y = sample), col = "white")
# trailing values
world <- map_data("world")
gg <- ggplot() + xlim(c(0,120)) +
ylim(c(-40,50)) #+ coord_map("ortho", orientation = c(10, 60, 0))
gg <- gg + geom_map(data=world, map=world,
aes(x=long, y=lat, map_id=region),
color="white", fill="#7f7f7f", size=0.05, alpha=1/4)
trailing <- gg + geom_point(data=d,
aes(x=longitude, y=latitude, colour=evi_leading)) +
scale_colour_viridis()
# compile the bird data
date = as.Date(sprintf("%s-%s-%s",df$year,df$month,df$day),"%Y-%m-%d")
sample = 1:nrow(df)
location = unique(data.frame(sample,date))
vi_matrix$vi[vi_matrix$vi < 0 ] = NA
start = data.frame(df$longitude,df$latitude)[-nrow(df),]
end = data.frame(df$longitude,df$latitude)[-1,]
diff = cbind(start,end)
travel_distance = apply(diff,1,function(x){
distm(c(x[1],x[2]),c(x[3],x[4]))/1000
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.