library(sf)
n=1500
bb <- rbind(c(-1281299,-761876.5),c(1915337,2566433.5))
bb.mat <- round(cbind(c(bb[1,1], bb[1,2], bb[1,2], bb[1,1]),
c(bb[2,1], bb[2,1], bb[2,2], bb[2,2])),2)
bbp <- st_sfc(st_polygon(list(rbind(bb.mat, bb.mat[1,]))))
pop <- st_as_sf(st_sample(bbp, n, type = "random"))
st_geometry(pop) <- "geometry"
pop$ID <- 1:nrow(pop)
pop$counts <- round(runif(nrow(pop), 1,250),0)
bd75 <- breeding.density(pop, pop='counts', p=0.75, b=8500, bw=6400)
plot(st_geometry(bd75$pop.area), border = NA,
main='75% breeding density areas', col="grey")
plot(st_geometry(pop), pch=20, col='black', add=TRUE)
plot(st_geometry(bd75$pop.pts), pch=20, col='red', add=TRUE)
legend("bottomright", legend=c("selected areas","selected sites", "all sites"),
bg="white", fill=c("grey","red", "black"), pt.cex = 2)
Run the code above in your browser using DataLab