Missing projection file in R's rgdal package for geospatial analysis

1.8k views Asked by At

I'm having a problem I can't solve with rgdal in which the projection file seems to be missing. This is the error I get:

proj4string(d) <- CRS("+init=epsg:28992")

Error in CRS("+init=epsg:28992") : no system list, errno: 2

It's confusing because when I load the package, it seems to successfully autodetect the PROJ.4 files:

> library(rgdal)
rgdal: version: 0.9-2, (SVN revision 526)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.11.2, released 2015/02/10
Path to GDAL shared files:
Loaded PROJ.4 runtime: Rel. 4.9.1, 04 March 2015, [PJ_VERSION: 491]
Path to PROJ.4 shared files: (autodetected)

But when I do this, it returns zero:

.Call("PROJcopyEPSG", tempfile(), PACKAGE = "rgdal")

The only answer I've found from googling this and searching SO is that epsg has to be lowercase, which it is in my code.

I'm on a Mac running Yosemite, with R 3.2.0, and working inside RStudio (version 0.99.441). Other packages and versions from my session info:

rgeos_0.3-8          ggmap_2.4            ggplot2_1.0.1        rgdal_0.9-2
leaflet_0.0.15       tidyr_0.2.0          dplyr_0.4.1
UScensus2010blk_1.00 UScensus2010_0.11    foreign_0.8-63
maptools_0.8-36      sp_1.1-0
1

There are 1 answers

1
Phil On BEST ANSWER

I had a quick Google and came across this post which suggests this was an OS X error where the packages were built incorrectly.

On my Mac system, I wasn't able to reproduce your error, so for what it's worth I installed my versions of rgdal and rgeos from http://www.kyngchaos.com/software:frameworks Maybe you can reinstall your versions of these packages and see if this resolves the issue? I would also update sp at the same time.

As a workaround, you might be able to specify the projection manually. The proj string for your projection can be obtained from: http://spatialreference.org/ref/epsg/amersfoort-rd-new/

So, for example, instead of:

proj4string(d) <- CRS("+init=epsg:28992")

you could specify:

proj4string(d) <- CRS("+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +no_defs ")

Not an answer, maybe, but worth a try? Good luck.