0

我正在尝试使用 adehabitatHR 使用遥测数据来估计家庭范围大小。每次我创建一个 SpatialPointsDataFrame 时,它​​都会对我的 UTM 位置的 y 坐标进行四舍五入。我尝试将 UTM 保存为整数、数字、在导入 .csv 之前删除 NA、在导入 .csv 后删除 NA、作为 .txt 文件导入(以防 excel 中存在错误)等。

这是控制台输出:

> data<-read.csv("C:/Workspace/URAM/Data/HomeRange/NEW_TelemetryLocs_AllBears_asof_9Sept19_noNAs.csv", header=T)
> 
> summary(data)
     Alias           Order      Sex          AnimalID           X                Y          
 Brandy : 2839   Min.   :   1   F:15546   102-16 : 2839   Min.   :397286   Min.   :5236180  
 Bernie : 2674   1st Qu.: 306   M:11650   06-16  : 2674   1st Qu.:406966   1st Qu.:5251887  
 Eve    : 2646   Median : 635             01-18  : 2646   Median :413166   Median :5258742  
 Deedee : 2606   Mean   :1239             17-17  : 2606   Mean   :412579   Mean   :5257164  
 Buddha : 2346   3rd Qu.:2018             04-17  : 2346   3rd Qu.:418419   3rd Qu.:5262669  
 Bailey : 1192   Max.   :5583             12-17  : 1192   Max.   :432690   Max.   :5291985  
 (Other):12893                            (Other):12893                                     
> head(data)
     Alias Order Sex AnimalID        X       Y
1 Calliope   128   F    19-22 432690.3 5262636
2 Calliope   191   F    19-22 432522.3 5262409
3 Calliope   127   F    19-22 432491.0 5263274
4 Calliope   189   F    19-22 432466.3 5262413
5 Calliope   190   F    19-22 432376.1 5262121
6 Calliope   202   F    19-22 432262.3 5264390
> dim(data)
[1] 27196     6
> str(data)
'data.frame':   27196 obs. of  6 variables:
 $ Alias   : Factor w/ 26 levels "Artemis","Bailey",..: 9 9 9 9 9 9 9 9 9 9 ...
 $ Order   : int  128 191 127 189 190 202 201 188 129 422 ...
 $ Sex     : Factor w/ 2 levels "F","M": 1 1 1 1 1 1 1 1 1 1 ...
 $ AnimalID: Factor w/ 26 levels "01-18","01-19",..: 26 26 26 26 26 26 26 26 26 26 ...
 $ X       : num  432690 432522 432491 432466 432376 ...
 $ Y       : num  5262636 5262409 5263274 5262413 5262121 ...
> test.sp<-SpatialPointsDataFrame(data[,5:6],data = data, coords.nrs = 5:6,
+                                  match.ID = TRUE,
+                                  proj4string=CRS("+proj=utm +zone=10+datum=NAD83+ellps=GRS80"))
> head(test.sp)
        coordinates    Alias Order Sex AnimalID        X       Y
1 (432690, 5262640) Calliope   128   F    19-22 432690.3 5262636
2 (432522, 5262410) Calliope   191   F    19-22 432522.3 5262409
3 (432491, 5263270) Calliope   127   F    19-22 432491.0 5263274
4 (432466, 5262410) Calliope   189   F    19-22 432466.3 5262413
5 (432376, 5262120) Calliope   190   F    19-22 432376.1 5262121
6 (432262, 5264390) Calliope   202   F    19-22 432262.3 5264390
Coordinate Reference System (CRS) arguments: +proj=utm +zone=10+datum=NAD83+ellps=GRS80 
> 

如果我在 R 中手动输入 6 行数据,它似乎可以工作:

> Alias<-c("Brandy","Brandy","Brandy","Brandy","Brandy","Brandy")
> Sex<-c("F","F","F","F","F","F")
> Order<-c(5,6,7,8,9,10)
> X<-c(409483,409481,409442,409438,409443,409576)
> Y<-c(5263356,5263356,5263335,5263340,5263342,5263685)
> test2<-data.frame(Alias,Sex,Order,X,Y)
> head(test2)
   Alias Sex Order      X       Y
1 Brandy   F     5 409483 5263356
2 Brandy   F     6 409481 5263356
3 Brandy   F     7 409442 5263335
4 Brandy   F     8 409438 5263340
5 Brandy   F     9 409443 5263342
6 Brandy   F    10 409576 5263685
> test2.sp<-SpatialPointsDataFrame(test2[,4:5],data = test2, coords.nrs = 4:5,
+                                  match.ID = TRUE,
+                                  proj4string=CRS("+proj=utm +zone=10+datum=NAD83+ellps=GRS80"))
> 
> test2.sp
        coordinates  Alias Sex Order      X       Y
1 (409483, 5263356) Brandy   F     5 409483 5263356
2 (409481, 5263356) Brandy   F     6 409481 5263356
3 (409442, 5263335) Brandy   F     7 409442 5263335
4 (409438, 5263340) Brandy   F     8 409438 5263340
5 (409443, 5263342) Brandy   F     9 409443 5263342
6 (409576, 5263685) Brandy   F    10 409576 5263685

但是,如果我使用坐标()命令创建 SpatialPointsDataFrame,使用手动输入的数据,结果是一个四舍五入的 Y 坐标:

> coordinates(test2)<-c("X","Y")
> head(test2)
        coordinates  Alias Sex Order
1 (409483, 5263360) Brandy   F     5
2 (409481, 5263360) Brandy   F     6
3 (409442, 5263340) Brandy   F     7
4 (409438, 5263340) Brandy   F     8
5 (409443, 5263340) Brandy   F     9
6 (409576, 5263680) Brandy   F    10
Coordinate Reference System (CRS) arguments: NA 

任何帮助或建议将不胜感激。

4

1 回答 1

1

舍入发生在对象的打印中,而不是在内部表示或后续计算中。

于 2020-01-30T07:59:06.510 回答