[R-pkg-devel] how to call PROJ.4 C code in a package?

Roger Bivand Roger.Bivand at nhh.no
Tue May 26 21:14:06 CEST 2015


I'm sorry to be late to the party (one is offline occasionally), but all 
the advice given so far is at best only partially correct.

Use of PROJ.4 is crucially conditional on access to PROJ_LIB a shell 
variable setting the address of metadata files not included in the C 
source. PROJ.4 without this access is very limited, not least because the 
EPSG listing of projections is not available, not to mention a small file 
of default values that recently floored rgdal and other packages using its 
PROJ.4 facilities (PROJ.4 4.9.1 omitted the file by mistake).

At present, oce does not ship with PROJ_LIB at all. I agree that it does 
not need to ship with the PROJ.4 C source, and should, like rgdal and 
proj4, use the system PROJ.4 (or the CRAN PROJ.4). Only rgdal checks in 
./configure for settings related to PROJ_LIB. Using PROJ.4 externally 
makes sense because of version shifting and missed bug fixes (there were 
some bad bugs before the aborted 4.9.0 release), and crucially updated 
metadata files. Using a single PROJ.4 on a platform avoids different 
applications seeing possibly different metadata.

My guess would be that anything you might need to do can be done using 
function stubs exported by rgdal for use in raster (the package). You are 
free to choose not to use sp objects, but you'll find that the high-level 
support for these in rgdal is robust and well-motivated.

If you go for the proj4 rather than rgdal solution, do make sure that the 
CRAN Windows and OSX binaries are built with the metadata PROJ_LIB copied 
to the binary packages.

Again, apologies for not jumping in at the right time.


PS. Please also note that PROJ.4 is moving to


Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no

More information about the R-package-devel mailing list