首页 > 解决方案 > Rdgal 不能很好地保存 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\
          

标签: rsprgdal

解决方案


这是与 rgdal/sp 中从 PROJ4 更改为 PROJ6 相关的问题。对您来说,这个问题有点深,因为该camtrapR软件包尚未更新以处理 PROJ6。您可以在此处阅读有关向 PROJ6 过渡的更多信息。

无需深入研究,您的解决方案就是降级到旧版本的spand rgdal.

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

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


推荐阅读