Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmap() not working on a single individual. #23

Closed
LouisMK opened this issue Nov 16, 2020 · 2 comments
Closed

fmap() not working on a single individual. #23

LouisMK opened this issue Nov 16, 2020 · 2 comments

Comments

@LouisMK
Copy link

LouisMK commented Nov 16, 2020

When I tried running the fmap() function on data for a single individual. It would plot all data points in the same colour and no index would appear.
Both the fit_ssm and the fit_mpm worked fine and when the fit_mpm was plotted the colour of the graph was varied and the index also appeared.

I tried joining the ssm and mpm manually as following

#joining movement persistence values to location values
fmp_loc <- foieGras::join(my_ssm,my_mpm, as_sf=F)

#Then plot, color by movement persistence
ggplot(fmp_locs) +
geom_point(aes(lon, lat, colour = g)) +
scale_colour_viridis_c(limits = c(0,1))

And this worked fine.

I also tried to do all of it with the example data in the package, ellie and ellies and that also had the same problem with fmap working fine on ellies, but only giving a single colour and no index on ellie.

I have added some screenshots and a copy of the script (with ellie and ellies) below.

Desktop

  • macOS Catalina 10.15.6
  • RStudio, version 1.3.1093

Rplot1
Rplot2
Rplot3
Rplot4

library(ggplot2)
library(ggmap)
library(ggsn)
library(foieGras)
library(dplyr)

#importing the data from within foiegras
data(ellie, package = "foieGras")
head(data.frame(ellie))

data(ellies, package = "foieGras")
head(data.frame(ellies))

#fit example with 2 elephant seals
data("ellies")
fit2 <- fit_ssm(ellies, model = "crw", time.step = 24, verbose = 0)
fit2$ssm[1]
#plotting graphs
plot(fit2, what = "predicted", type = 1)
plot(fit2, what = "fitted", type = 2)

#fit example with 1 elephant seal
fit1<- fit_ssm(ellie, model = "rw", time.step = 48, verbose = 0)
plot(fit1, what = "predicted", type = 1)
plot(fit1, what = "fitted", type = 2)
#plotting graphs
plot(fit1, what = "predicted", type = 1)
plot(fit1, what = "fitted", type = 2)

#for two elephant seals
fmp2 <- fit2 %>%
grab(what = "predicted", as_sf = FALSE) %>%
select(id, date, lon, lat) %>%
fit_mpm(model = "jmpm", verbose = 0)
plot(fmp2)
#Joining ssm and mpm and plotting on a map
fmap(fit2, fmp2, what = "predicted", crs = "+proj=stere +lon_0=99 +units=km +ellps=WGS84")

#for one elephant seal
fmp1 <- fit1 %>%
grab(what = "predicted", as_sf = FALSE) %>%
select(id, date, lon, lat) %>%
fit_mpm(model = "mpm", verbose = 0)
plot(fmp1)

#Joining ssm and mpm and plotting on a map (doesn't work on a single individual)
fmap(fit1, fmp1, what = "predicted", crs = "+proj=stere +lon_0=99 +units=km +ellps=WGS84")

@ianjonsen
Copy link
Owner

Thanks for pointing this out. Should be fixed in master branch now

@ianjonsen
Copy link
Owner

fmap(fit1, fmp1, what = "predicted", crs = "+proj=stere +lon_0=99 +units=km +ellps=WGS84") call now yields expected result:

Rplot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants