Rdgal 不能很好地保存 shapefile

Rdgal don't working well to save a shapefile

我正在尝试使用“rgdal”包保存具有检测率的 shapefile 格式,但出现以下错误:

Error in showSRID(uprojargs, format = "PROJ", multiline = "NO") : 
  Can't parse PROJ.4-style parameter string
+proj=longlat +ellps=WGS84+datum=WGS84+no_def

如何修复?

生殖实例

library(rgdal)
library(sp)
library(camtrapR)

Long<-c(-53.59390711, -53.58148303)
Lat<-c(-4.633924739, -4.6340598)
df1<-data.frame(Long,Lat)
df1$Station<-NA
df1[df1$Long=="-53.59390711",]$Station<-"w"
df1[df1$Long=="-53.58148303",]$Station<-"z"

Station<-c("w","w","w","w","w","w","w","w","w","w","z","z","z","z","z","z","z","z","z","z")
Species<-c("a","a","a","b","b","b","c","c","c","c","a","b","b","b","b","b","c","c","c","c")
df2<-data.frame(Station, Species)


detectionMaps(CTtable=df1,recordTable=df2,Xcol="Long",Ycol="Lat",stationCol="Station",speciesCol="Species",speciesToShow="a",richnessPlot=FALSE,speciesPlots=FALSE,
writeShapefile=TRUE,shapefileDirectory=tempdir(),shapefileName="sp_a", shapefileProjection="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_def")

#The shapefile should be created in this directory: C:\Users\...\AppData\Local\Temp\
          

这个问题与 rgdal/sp 中从 PROJ4 到 PROJ6 的更改有关。对你来说,问题有点深,因为 camtrapR 包还没有更新来处理 PROJ6.You 可以阅读更多关于过渡到 PROJ6 here.

在不深入研究的情况下,您的解决方案是降级到 sprgdal.

的旧版本

对于 sp (< 1.4-2) 和 rgdal (< 1.5-8)。

编辑:由于您可以自己定义 PROJ 字符串,因此您也可以先尝试:“+init=epsg:4326”。这可能仍然有效。