#
# Obrada telemetrijskih podataka za surog orla
# Udruga BIOM, 2019
#

library(tidyverse)
## Registered S3 methods overwritten by 'ggplot2':
##   method         from 
##   [.quosures     rlang
##   c.quosures     rlang
##   print.quosures rlang
## Registered S3 method overwritten by 'rvest':
##   method            from
##   read_xml.response xml2
## ── Attaching packages ────────────────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.1.1       ✔ purrr   0.3.2  
## ✔ tibble  2.1.1       ✔ dplyr   0.8.0.1
## ✔ tidyr   0.8.3       ✔ stringr 1.4.0  
## ✔ readr   1.3.1       ✔ forcats 0.4.0
## ── Conflicts ───────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(raster)
## Loading required package: sp
## 
## Attaching package: 'raster'
## The following object is masked from 'package:dplyr':
## 
##     select
## The following object is masked from 'package:tidyr':
## 
##     extract
library(sp)
library(spdplyr)
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
library(rgeos)
## rgeos version: 0.4-3, (SVN revision 595)
##  GEOS runtime version: 3.7.1-CAPI-1.11.1 
##  Linking to sp version: 1.3-1 
##  Polygon checking: TRUE
library(httr)

source('telemetry_f.R')

# priprema administrativnih podloga
hr <- getData(name = "GADM", country = 'HRV', level = 0, path = 'data/')

# definiranje CRS-ova
wgs84 <- crs(hr)
htrs96 <- crs("+proj=tmerc +lat_0=0 +lon_0=16.5 +k=0.9999 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs")

# reprojiciranje hr poligona u htrs96 koordinatni sustav
hr_proj <- spTransform(hr, htrs96)

# Ulazni podaci -----------------------------------------------------------

# definiranje pozicija gnijezda

nest_surkan <- SpatialPoints(list(longitude = 16.090257, latitude = 44.117754), proj4string = wgs84) %>% 
  spTransform(htrs96)
nest_maleni <- SpatialPoints(list(longitude = 16.154080, latitude = 43.927930), proj4string = wgs84) %>% 
  spTransform(htrs96)

# Ecotone (Maleni, Surkan)
auth <- readLines("data/auth.txt")

mj01 <- get_ecotone_data(2017, 3, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   GPSIntervals = col_character(),
##   N_satellites = col_character()
## )
## See spec(...) for full column specifications.
mj02 <- get_ecotone_data(2017, 4, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj03 <- get_ecotone_data(2017, 5, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj04 <- get_ecotone_data(2017, 6, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj05 <- get_ecotone_data(2017, 7, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj06 <- get_ecotone_data(2017, 8, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj07 <- get_ecotone_data(2017, 9, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj08 <- get_ecotone_data(2017, 10, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj09 <- get_ecotone_data(2017, 11, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj10 <- get_ecotone_data(2017, 12, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj11 <- get_ecotone_data(2018, 1, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj12 <- get_ecotone_data(2018, 2, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj13 <- get_ecotone_data(2018, 3, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj14 <- get_ecotone_data(2018, 4, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj15 <- get_ecotone_data(2018, 5, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj16 <- get_ecotone_data(2018, 6, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj17 <- get_ecotone_data(2018, 7, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj18 <- get_ecotone_data(2018, 8, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj19 <- get_ecotone_data(2018, 9, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj20 <- get_ecotone_data(2018, 10, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj21 <- get_ecotone_data(2018, 11, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj22 <- get_ecotone_data(2018, 12, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   GPSIntervals = col_character(),
##   VHFTelemetry = col_character(),
##   GSMSignal = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj23 <- get_ecotone_data(2019, 1, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj24 <- get_ecotone_data(2019, 2, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj25 <- get_ecotone_data(2019, 3, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj26 <- get_ecotone_data(2019, 4, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj27 <- get_ecotone_data(2019, 5, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
mj28 <- get_ecotone_data(2019, 6, "croeagle", auth[1], auth[2])
## No encoding supplied: defaulting to UTF-8.
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   GPSTime = col_datetime(format = ""),
##   SMSTime = col_datetime(format = ""),
##   GpsDescription = col_character(),
##   VHFTelemetry = col_character(),
##   N_satellites = col_logical(),
##   Speed_knots = col_logical(),
##   Altitude = col_logical(),
##   Light = col_logical(),
##   Acc_X = col_logical(),
##   Acc_Y = col_logical(),
##   Acc_Z = col_logical()
## )
## See spec(...) for full column specifications.
# mj29 <- get_ecotone_data(2019, 7, "croeagle", auth[1], auth[2])

tab <- bind_rows(mj01, mj02, mj03, mj04, mj05, mj06, mj07, mj08, mj09, mj10, mj11, mj12,
                 mj13, mj14, mj15, mj16, mj17, mj18, mj19, mj20, mj21, mj22, mj23, mj24,
                 mj25, mj26, mj27, mj28)
names(tab)[names(tab) == "Longtitude"] <- "Longitude" # popravljanje tipfelera u ecotone formatu
tab$GpsID <- tab$GpsDescription

maleni <- mkspat(tab, crs = htrs96) %>% 
  movestats(nest = nest_maleni) %>% 
  filter(GpsID == "CROE01" & GPSTime < ymd("2017-07-09"))

surkan <- mkspat(tab, crs = htrs96) %>% 
  movestats(nest = nest_surkan) %>% 
  filter(GpsID == "CROE02" & GPSTime > ymd("2017-06-30") & GPSTime < ymd("2018-04-27")) %>% 
  mutate(UTC_date = date(GPSTime))

# Ornitela (Otto)

orn <- read_csv("data/data-aquchr/otto/181180_20190624_071000.csv")
## Warning: Missing column names filled in: 'X23' [23]
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   UTC_datetime = col_datetime(format = ""),
##   UTC_date = col_date(format = ""),
##   UTC_time = col_time(format = ""),
##   datatype = col_character(),
##   X23 = col_logical()
## )
## See spec(...) for full column specifications.
otto <- mkspat(orn, crs = htrs96) %>% 
  mutate(GPSTime = UTC_datetime,
         GpsID = "OTTO") %>% 
  filter(GPSTime > ymd("2018-06-29") & Latitude != 0) %>% 
  movestats(nest = nest_surkan) # isto gnijezdo kao Surkan

# Kalkulacije po danima ---------------------------------------------------

analiza_surkan <- tbl_df(surkan) %>% 
  group_by(UTC_date) %>% 
  summarise(mean_distance = mean(Dist_from_nest)/1000,
            median_distance = median(Dist_from_nest)/1000,
            total_distance = sum(Distance)/1000)

analiza_otto <- tbl_df(otto) %>% 
  group_by(UTC_date) %>% 
  summarise(mean_distance = mean(Dist_from_nest)/1000,
            median_distance = median(Dist_from_nest)/1000,
            total_distance = sum(Distance)/1000)

# write_excel_csv(analiza_surkan, "analiza_surkan.csv")
# write_excel_csv(analiza_otto, "analiza_otto.csv")

# Plot --------------------------------------------------------------------

ggplot(data = analiza_otto) + 
  aes(x = UTC_date, y = total_distance) + 
  geom_line() + 
  scale_x_date(breaks = scales::pretty_breaks(n = 10)) +
  scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) +
  labs(title = "Otto - Kumulativno po danu") +
  ylab("Prijeđena kumulativna udaljenost po danu (km)") +
  xlab("Vrijeme (dani od markiranja)")

ggplot(data = analiza_otto) + 
  aes(x = UTC_date, y = median_distance) + 
  geom_line() + 
  scale_x_date(breaks = scales::pretty_breaks(n = 10)) +
  scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) +
  labs(title = "Otto - Medijan udaljenosti od gnijezda") +
  ylab("Medijan udaljenosti od gnijezda po danu (km)") +
  xlab("Vrijeme (dani od markiranja)")

ggplot(data = analiza_otto) + 
  aes(x = UTC_date, y = mean_distance) + 
  geom_line() + 
  scale_x_date(breaks = scales::pretty_breaks(n = 10)) +
  scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) +
  labs(title = "Otto - Prosječna udaljenost od gnijezda") +
  ylab("Prosječna udaljenost od gnijezda po danu (km)") +
  xlab("Vrijeme (dani od markiranja)")

ggplot(data = analiza_surkan) + 
  aes(x = UTC_date, y = total_distance) + 
  geom_line() + 
  scale_x_date(breaks = scales::pretty_breaks(n = 10)) +
  scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) +
  labs(title = "Surkan - Kumulativno po danu") +
  ylab("Prijeđena kumulativna udaljenost po danu (km)") +
  xlab("Vrijeme (dani od markiranja)")

ggplot(data = analiza_surkan) + 
  aes(x = UTC_date, y = median_distance) + 
  geom_line() + 
  scale_x_date(breaks = scales::pretty_breaks(n = 10)) +
  scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) +
  labs(title = "Surkan - Medijan udaljenosti od gnijezda") +
  ylab("Medijan udaljenosti od gnijezda po danu (km)") +
  xlab("Vrijeme (dani od markiranja)")

ggplot(data = analiza_surkan) + 
  aes(x = UTC_date, y = mean_distance) + 
  geom_line() + 
  scale_x_date(breaks = scales::pretty_breaks(n = 10)) +
  scale_y_continuous(breaks = scales::pretty_breaks(n = 10)) +
  labs(title = "Surkan - Prosječna udaljenost od gnijezda") +
  ylab("Prosječna udaljenost od gnijezda po danu (km)") +
  xlab("Vrijeme (dani od markiranja)")