r语言 - MCP家庭范围与AdehabitatHR太小



我是使用r进行空间分析的新手。我试图计算日常家庭范围(MCP 100,后来的95和50%),主要使用r中的adehabitatHR包。我使用了我的同事提供的脚本,它一直为她工作。现在当我运行它的时候,它工作了,但是我收到的e-xx值太小了。我真的不知道哪里出了问题,我想这和投影有关,但是我太没有经验了,不知道哪个应该更好。

您可以看到下面的代码。也许有人知道怎么解决这个问题?

library (adehabitatHR)
library (sp)
library (scales)  # helps make Polygons partly transparent using the alpha argument below 
library(dplyr)
# Read data frame into R 
tab1<-read.csv(file="animals.csv",sep=",",header=TRUE)
# Remove two rows with NA´s 
tab1 <- tab1 [!is.na(tab1$x_) & !is.na(tab1$y_),]
# Only include three columns (AnimalID + Exp, x and y coordinates) for making MCP´s 
# Creating new ID to group days and AnimalID
tab2 <- tab1 [, c("id", "x_", "y_", "day", "month", "year")] # week, month, day + month
tab2$Time <- paste(tab2$day, tab2$month, sep= " ") #  day + month
tab2$Time2 <- paste(tab2$Time, tab2$year)
tab2$Mix <- paste(tab2$AnimalID, tab2$Time2, sep= " ") # id + time 
tab3 <- tab2 [, c("Mix", "x_", "y_")]
tibble(tab3)
# Check in tab2 which Animal has less than 5 GPS location
tab4 <- tab3 %>%
group_by(Mix) %>%
summarise(n = n())
# Filter data with less than 5 
tab5<-filter(tab4, n > 5)
tab6<-filter(tab4, n < 5)

# Remove rows from data set which have less than 5 GPS location
tab7 <- tab3 %>% 
filter(!grepl(" 31 May 2019", Mix))
tab8 <- tab7 %>% 
filter(!grepl(" 29 Jun 2019", Mix))
# Create a SpatialPointsDataFrame by defining the coordinates
coordinates(tab8) <- c("x_", "y_")
str(tab8)
# Set the coordinate reference system, (CRS) 
# The sample data are UTM points in WGS84 from zone 33N 
proj4string(tab8) <- CRS( "+proj=utm +zone=33N +datum=WGS84 +units=m +no_defs" )
animals.mcp <- mcp(tab8[, "Mix"], percent = 100, unin = "m", unout = "m2") 
as.data.frame(animals.mcp)

输出数据如下所示:

id         area
1 Dec 2019    1 Dec 2019 5.180087e-03
1 Feb 2020    1 Feb 2020 7.171711e-04
1 Jan 2020    1 Jan 2020 1.692209e-03
1 Jul 2019    1 Jul 2019 3.384402e-07
1 Jun 2019    1 Jun 2019 1.829374e-01
1 Nov 2019    1 Nov 2019 7.794313e-04
...

提前感谢!

所以我可以通过添加

来解决这个问题
coordinates(tab7) <- c("x_", "y_") 
proj4string(tab7) <- CRS("+init=epsg:4326") 
tab8 <- spTransform(tab7, CRS("+proj=utm +zone=33N +datum=WGS84 +units=m +no_defs"))

所以首先告诉R使用什么坐标系然后把它投影到必要的区域

希望这对有同样问题的人有所帮助!

相关内容

  • 没有找到相关文章

最新更新