Plot individuals home-range with Adehabitat

993 Views Asked by At

I am trying to put the name from the individuals of my research in a polygons home-range plot, but after many attempts I still can not achieve it.

Here and example of my data: X and Y are coordinates and id are individuals

X   Y   id          
29  29  4           
44  28  7           
57  57  5           
60  81  11          
32  41  4           
43  29  7           
57  57  5           
46  83  11          
32  41  4           
43  29  7           
57  56  5           
60  82  11          
35  40  4           
43  28  7           
62  55  5           
54  73  11          
27  40  4           
43  28  7           
61  54  5

First, i calculated the home-range of my data with MPC cp <- mcp((data)[,1],percent=95, unin = c("m"), unout = c("m2"))

And the plot it plot(cp, axes=TRUE, border = rainbow(12))

But i don´t kown which polygons correspond to each individual, and if possible i need to include the id of my individuals inside each polygon

Any help would be appreciated!!

Thanks

Juan

1

There are 1 best solutions below

4
On BEST ANSWER

Here is an example using the example data from the adehabitatHR package, since you not really providing a reproducible example.

library(adehabitatHR)
data("puechabonsp")

cp <- mcp(puechabonsp$relocs[, 1], percent=95, unin = c("m"), unout = c("m2"))

One way would be to use ggplot2 and sf:

library(sf)
library(tidyverse)

st_as_sf(cp) %>% ggplot(., aes(fill = id)) + geom_sf(alpha = 0.5) +
  scale_fill_discrete(name = "Animal id")

enter image description here