[R] Help with RGDAL

Michael Denslow michael.denslow at gmail.com
Wed Nov 4 11:51:33 CET 2009


Hi Charlie!

On Fri, Oct 30, 2009 at 5:16 PM, cls59 <chuck at sharpsteen.net> wrote:
>
>
> Pablo Alvarez-2 wrote:
>>
>>
>> Hello,
>> We (two mac users) have been attempting to install rgdal from
>> "http://www.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:
>
>  http://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:
>
>  http://www.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  http://www.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!


Sorry to jump in here so late but I just gave this a try. I usually
install rgdal from CRAN on windows or download the binary from
http://www.kyngchaos.com for Mac. I wanted to try your method from
building from source since the directions were so clear and
understandable. This is the first time I have done this and I am not
very terminal savvy.

I ran the last command above and get this message:


* installing to library ‘/Library/Frameworks/R.framework/Resources/library’
* installing *source* package ‘rgdal’ ...
gdal-config: /Library/Frameworks/GDAL.framework/unix/bin/gdal-config
/Library/Frameworks/R.framework/Resources/bin/config: line 143: make:
command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 144: make:
command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 220: make:
command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 143: make:
command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 144: make:
command not found
/Library/Frameworks/R.framework/Resources/bin/config: line 220: make:
command not found
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/Library/Frameworks/R.framework/Resources/library/rgdal’


It seem to be looking for the C compiler among other things. Can you
provide any help on this?

Thanks in advance,
Michael

> sessionInfo()
R version 2.10.0 Patched (2009-11-02 r50295)
x86_64-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] sp_0.9-44

loaded via a namespace (and not attached):
[1] grid_2.10.0     lattice_0.17-26 tools_2.10.0

>
> -Charlie
>
>
>
> -----
> Charlie Sharpsteen
> Undergraduate
> Environmental Resources Engineering
> Humboldt State University
> --
> View this message in context: http://old.nabble.com/Help-with-RGDAL-tp26135289p26137651.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Michael Denslow

Graduate Student & Adjunct Instructor
I.W. Carpenter Jr. Herbarium [BOON]
Department of Biology
Appalachian State University
Boone, North Carolina U.S.A.
-- AND --
Communications Manager
Southeast Regional Network of Expertise and Collections
sernec.org

36.214177, -81.681480 +/- 3103 meters




More information about the R-help mailing list