Pablo Alvarez-2 wrote:>
>
> Hello,
> We (two mac users) have been attempting to install rgdal from
> "kyngchaos.com/software:frameworks", given that it is
not
> available as a binary on the CRAN (binaries) of the "Package
Installer".
>
>
The GDAL library contains an impressive collection of utilities and also
leverages several other libraries such as HDF, netCDF and PROJ4, just to
name a few. Building and distributing a binary R package that contains the
GDAL library bloats the size of the package and causes redundancies if a
user already has GDAL installed somewhere else on their system. It also
creates a lot of extra work for the package maintainer.
This is probably done for Windows because a run-of-the-mill Windows system
is utterly incapable of building anything from source. Linux and OS X
systems are perfectly capable, so it is expected that you can build the
package from source and use your installed version of GDAL.
Pablo Alvarez-2 wrote:>
>
> I have also tried to solve this problem by looking on the net for an old
> question, and though I have found it, the answers do not help very much
> because our porgraming skills are embryonic.
>
>
> Our GIS professor has suggested we ask you guys how to proceed with the
> CRAN (source). Any suggestions or direction to an old document dealing
> with this?
>
> Thank you very much for your help,
> Pablo and Margarita
> PS. We have already installed: GDAL (for QGIS) and "sp" (for R)
>
>
I've built the GDAL library and installed rgdal a few times-- it's
typically
one of the first things I do after wiping or reinstalling my OS X system or
a Linux system. Building software from source can be a tricky business with
a steep learning curve-- but once you figure out some of the patterns it
becomes quite doable (as long as those darn platform-specific issues don't
cut you off at the kneecaps).
The rgdal package contains a Configure script that is run during
installation and attempts to locate the GDAL library. When building software
on Unix/Linux, there are three kinds of folders containing various items of
interest that compilers and linkers will frequently pester you about. These
are:
* "lib" folders-- these contain libraries that hold code you are
trying to
use.
* "include" folders-- these contain header files that tell the
compiler
how to use
the code in the libraries.
* "bin" folders-- these contain scripts and programs that may help
the
Configure script,
or the program you are building do the things they do.
I suspect the Configure script for the rgdal package only checks standard
Unix/Linux folders such as /usr/bin or /usr/local/lib. The Framework package
provided by William Kyngesburye installs GDAL Mac-Style, which means these
folders are located in:
/Library/Frameworks/GDAL.framework/unix/
And
/Library/Frameworks/PROJ.framework/unix/
Fortunately, R allows us to pass hints to configure during package
installation in order to help it find what it is looking for.
So, grab the source tarball of rgdal from:
cran.r-project.org/web/packages/rgdal/index.html
I'm also using the PROJ4 and GDAL frameworks installed by the GDAL Complete
framework, available from:
kyngchaos.com/software:frameworks
Also, make sure you have installed the "Developer Tools" contained on
your
OS X System Software CD as these provide C compilers and other tools needed
to build the code in the rdal package.
Now pop open a Terminal. Assuming you saved the package in your Downloads
folder, execute the following.
cd ~/Downloads
R CMD INSTALL rgdal_0.6-20.tar.gz
R will start to install the package, and then wipe out with a message that
includes:
Error: gdal-config not found
The gdal-config script distributed with GDAL could not be found.
If you have not installed the GDAL libraries, you can
download the source from gdal.org
If you have installed the GDAL libraries, then make sure that
gdal-config is in your path. Try typing gdal-config at a
shell prompt and see if it runs. If not, use:
--configure-args='--with-gdal-config=/usr/local/bin/gdal-config' echo
with
appropriate values for your installation.
gdal-config is a little script who's sole purpose is to tell Configure
scripts whatever they want to know about a GDAL installation. Scripts and
programs that accompany a library are commonly installed in a "bin"
folder.
So given what I've noted above about the install location used by the GDAL
framework, we can give rgdal's Configure script a hint:
R CMD INSTALL --configure-args=\
"--with-gdal-config=/Library/Frameworks/GDAL.framework/unix/bin/gdal-config"
\
rgdal_0.6-20.tar.gz
The R installer now spits out another error:
Error: proj_api.h not found.
If the PROJ.4 library is installed in a non-standard location,
use --configure-args='--with-proj-include=/opt/local/include'
for example, replacing /opt/local/* with appropriate values
for your installation. If PROJ.4 is not installed, install it.
PROJ4 has no "proj4-config" script, so we will probably need to tell
Configure where both the lib and include folders are. The following command:
R CMD INSTALL --configure-args=\
"--with-gdal-config=/Library/Frameworks/GDAL.framework/unix/bin/gdal-config
\
--with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib \
--with-proj-include=/Library/Frameworks/PROJ.framework/unix/include" \
rgdal_0.6-20.tar.gz
Should provide Configure with enough information to build and install the
package.
When smashed onto one line (for easier copying and pasting) the above
command is:
R CMD INSTALL
--configure-args="--with-gdal-config=/Library/Frameworks/GDAL.framework/unix/bin/gdal-config
--with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib
--with-proj-include=/Library/Frameworks/PROJ.framework/unix/include"
rgdal_0.6-20.tar.gz
Hope this helps!
-Charlie
-----
Charlie Sharpsteen
Undergraduate
Environmental Resources Engineering
Humboldt State University
--
View this message in context:
old.nabble.com/Help-with-RGDAL-tp26135289p26137651.html
Sent from the R help mailing list archive at Nabble.com.