I discovered this trying to see if I could use a vector of descending values for the levels argument to make the geometries save in descending order. When I did, the levels vector in the dataframe were in descending order but the geometries were in ascending (by default it seems). I tested it on MCPs just to see and the geometries wrote in ascending order but so did the levels, so all good there. I am not sure about the other hr_ functions.
f <- amt_fisher %>%
make_track(x_,y_,t_, id=id, sex=sex, crs=5070) %>%
nest(locs = c(x_,y_,t_))
hr <- f %>%
mutate(kde = map(locs, ~hr_kde(., levels=c(0.95, 0.85, 0.6, 0.5))),
mcp = map(locs, ~hr_mcp(., levels=c(0.95, 0.85, 0.6, 0.5))))
hr_area(hr$mcp[[1]])
hr_area(hr$kde[[1]])
> hr_area(hr$mcp[[1]])
# A tibble: 4 x 3
level what area
<dbl> <chr> <dbl>
1 0.5 estimate 7574937.
2 0.6 estimate 9253790.
3 0.85 estimate 17693784.
4 0.95 estimate 19753529.
> hr_area(hr$kde[[1]])
# A tibble: 4 x 3
level what area
<dbl> <chr> <dbl>
1 0.95 estimate 7842050.
2 0.85 estimate 10137466.
3 0.6 estimate 18998986.
4 0.5 estimate 27258422.
Since this is in the same ballpark, I would also like to suggest making the geometries save in descending order as the default so that home range dataframes can be converted with hr_to_sf and the product can be plotted and the geometries drawn in the correct order. Currently, if you plot the sf objects (or exported .shp files in Arc) as it is, the larger level home range gets drawn over the smaller and you can't see them all unless fill=NA.
This is fixed with arrange(desc(levels)) after the fact, but that's putting an essential step in plotting on the user and I could not find it addressed in the documentation.
I discovered this trying to see if I could use a vector of descending values for the levels argument to make the geometries save in descending order. When I did, the levels vector in the dataframe were in descending order but the geometries were in ascending (by default it seems). I tested it on MCPs just to see and the geometries wrote in ascending order but so did the levels, so all good there. I am not sure about the other
hr_
functions.Since this is in the same ballpark, I would also like to suggest making the geometries save in descending order as the default so that home range dataframes can be converted with
hr_to_sf
and the product can be plotted and the geometries drawn in the correct order. Currently, if you plot thesf
objects (or exported .shp files in Arc) as it is, the larger level home range gets drawn over the smaller and you can't see them all unless fill=NA. This is fixed witharrange(desc(levels))
after the fact, but that's putting an essential step in plotting on the user and I could not find it addressed in the documentation.