[R-sig-Geo] gdalUtils 0.2.0 now on CRAN

Rainer M Krug Rainer at krugs.de
Thu Jan 9 21:07:42 CET 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/09/14, 18:46 , Jonathan Greenberg wrote:
> Rainer:
Hi


> 
> Responses below!
> 
> On Thu, Jan 9, 2014 at 2:28 AM, Rainer M Krug <Rainer at krugs.de>
> wrote:
> 
> 
> Very nice - haven't tried any working examples, but it installs on
> a mac without problems and finds the gdal installation installed
> via homebrew.
> 
> But I have some questions:
> 
> The automatic search is nice - but I unlinked gdal via homebrew,
> i.e. the links to the binaries and libraries are not in the path
> anymore, and I could not load gdalUtils anymore, as the gdalUtils
> did not find the libraries anymore (understandable). But it seams,
> that gdalUtils did not search for gdal, which is installed as a
> Framework as well. Now I removed gdalUtils again and installed it
> again, with gdal still unlinked, but it did not install as it did
> not find the gdal libraries, despite gdal being available in a
> framework (see http://www.kyngchaos.com/software/frameworks for the
> ones installed - they are quite popular, and required, among GRASS
> and QGIS users on Mac).
> 
>> Quick question: did you try restarting R AFTER you unlinked the 
>> homebrew version?  Here's why I ask: the first time you run ANY 
>> gdalUtils in a session, what it does is spiders your system for 
>> working GDAL installations (in fact, it looks for the frameworks 
>> first).  After this first time, it won't re-scan the drive unless
>> you do one of two things: 1) restart R and re-load GDALUtils, or
>> 2) run gdal_setInstallation(rescan=TRUE)


Yes, I restarted R afterwards - see transcript below:

####################################
Rainers-MacBook-Pro-2:~ rainerkrug$ brew unlink gdal
Unlinking /usr/local/Cellar/gdal/1.10.1... 163 links removed
Rainers-MacBook-Pro-2:~ rainerkrug$ R

R version 3.0.2 Patched (2014-01-07 r64692) -- "Frisbee Sailing"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin10.8.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> library(gdalUtils)
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object
'/Users/rainerkrug/Library/R/3.0/library/rgdal/libs/rgdal.so':
  dlopen(/Users/rainerkrug/Library/R/3.0/library/rgdal/libs/rgdal.so,
6): Library not loaded: /usr/local/lib/libgdal.1.dylib
  Referenced from:
/Users/rainerkrug/Library/R/3.0/library/rgdal/libs/rgdal.so
  Reason: image not found
Error: package or namespace load failed for ‘gdalUtils’
> 
####################################

and I obviously can not call the command, as the package is not loaded.

But I just realized what the problem is: the importing on rgdal. If I
unlink, rgdal does not load anymore as it is compiled using the
homebrew gdal version, and consequently gdalUtils does not load
anymore. So the problem is not directly with gdalUtils. But this
raises an important question: what happens if rgdal and gdalUtils are
using different gdal versions? I think this could call for
inconsistencies.

As gdalUtils depends on rgdal, I would actually suggest to use the
same gdal installation as rgdal, if this is possible.

> 
> Question 1:
> 
> Would it be possible, to include the gdal Frameworks in the search
> path?
> 
>> These are the common locations it searches for, before it
>> attempts a brute-force search of your whole drive:
> 
>> if (.Platform$OS=="unix") { common_locations <- c( # UNIX
>> systems "/usr/bin", "/usr/local/bin", # Mac # Kyngchaos
>> frameworks: "/Library/Frameworks/GDAL.framework/Programs", #
>> MacPorts: "/opt/local/bin" ) } if (.Platform$OS=="windows") { 
>> common_locations <- c( "C:\\Program Files", "C:\\Program Files
>> (x86)", "C:\\OSGeo4W" ) }
> 
>> I use those frameworks, and the function worked for me, but let
>> me know if it failed to find yours (perhaps I'll strip the
>> /Programs from the search path?)  It is easy for me to add new
>> search locations, so if there are other common locations for ANY
>> OS just let me know.
> 

As mentioned above, the problem is the importing of rgdal.

> 
> At the end is a layout of the directory structure of the gdal
> frameworks.
> 
> Question 2:
> 
> Is it (or would it) be possible to manually set the installation
> of gdal to be used? This would make comparison of versions of gdal
> as well as reproducible research much easier.
> 
>> Yes, we can add in this functionality at a future date.  Right
>> now, you can check to see what your installs are by: 
>> gdal_setInstallation(rescan=TRUE) 
>> getOption("gdalUtils_gdalPath")
> 
>> In general, gdalUtils will use the first element of the 
>> getOption("gdalUtils_gdalPath"), which is chosen by the most
>> recent version (by date).

As mentioned above, due to the importing of rgdal, I would suggest to
use the same version as rgdal, if possible, to keep it consistent and
reproducible.

> 
> Question 3:
> 
> I can't test it right now, but I assume that gdalUtils does search
> for a new gdal installation if it can't find the one used before?
> Is there a way of initiating the search (and selection) if a newer
> version has been installed?
> 
>> Yep, as I said either restart R or run: 
>> gdal_setInstallation(rescan=TRUE)

OK.

Hope my comments are useful,

Rainer

> 
> 
> Thanks for a very neat package,
> 
> Rainer
> 
> Directory structure of the GDAL.Framework on a MAC:
> 
> /Library/Frameworks/GDAL.framework/ ├── Headers ->
> Versions/Current/Headers ├── Programs -> Versions/Current/Programs 
> ├── Resources -> Versions/Current/Resources ├── Versions │   ├──
> 1.10 │   │   ├── Headers │   │   ├── Libraries │   │   │   └──
> ogdi │   │   ├── PlugIns │   │   ├── Programs │   │   ├── Python │
> │   │   ├── 2.6 │   │   │   │   └── site-packages │   │   │   │
> └── osgeo │   │   │   └── 2.7 │   │   │       └── site-packages │
> │   │           └── osgeo │   │   ├── Resources │   │   │   ├──
> doc │   │   │   │   └── gdal │   │   │   │       ├── java │   │   │
> │       │   ├── org │   │   │   │       │   │   └── gdal │   │   │
> │       │   │       ├── gdal │   │   │   │       │   │       ├──
> gdalconst │   │   │   │       │   │       ├── ogr │   │   │   │
> │   │       └── osr │   │   │   │       │   └── resources │   │   │
> │       └── ogr │   │   │   └── gdal │   │   └── unix │   │
> ├── bin │   │       ├── include -> ../Headers │   │       └── lib │
> ├── 1.9 │   │   ├── Headers │   │   ├── Libraries │   │   │   └──
> ogdi │   │   ├── PlugIns │   │   ├── Programs │   │   ├── Python │
> │   │   ├── 2.6 │   │   │   │   └── site-packages │   │   │   │
> └── osgeo │   │   │   └── 2.7 │   │   │       └── site-packages │
> │   │           └── osgeo │   │   ├── Resources │   │   │   ├──
> doc │   │   │   │   └── gdal │   │   │   │       ├── java │   │   │
> │       │   ├── org │   │   │   │       │   │   └── gdal │   │   │
> │       │   │       ├── gdal │   │   │   │       │   │       ├──
> gdalconst │   │   │   │       │   │       ├── ogr │   │   │   │
> │   │       └── osr │   │   │   │       │   └── resources │   │   │
> │       └── ogr │   │   │   └── gdal │   │   └── unix │   │
> ├── bin │   │       ├── include -> ../Headers │   │       └── lib │
> └── Current -> 1.10 └── unix -> Versions/Current/unix
> 
> 
>>>> 
>>>> Cheers!
>>>> 
>>>> --j
>>>> 
> 
> 
> 
> 

- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer at krugs.de

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSzwGOAAoJENvXNx4PUvmCNcUH/RHSZJgaIbMsipZUD2dCL+Fx
dTquYOrt7v1w1JZ+nrVNcU65o9Dp91GmGQ2w61EF9l+59y3e91UynFu94/OLEZIb
37aZvss28lsRW1MokJZRBWor8z3EQNY2kq8c4GOZoMBIRTT+LK9Mvv/EQXcntP0P
LXyTb3fXdXE/GePOteiG2vyCzu36maENbfbY5nqVIiu+qO5H60HcFmJR7FcX1Ty/
Q8BQ4vMkJQm6tJ2ozUJNHccgb0klNqUEp1Kwmiufen1m4jN3Qv9v1epAFLz6KArx
7j5O4pGLzdQXbnEjLSCwS1GL8P6+jWXzbiZA1KX+FI2xypu762b5tKXcw5eVw6w=
=tCRS
-----END PGP SIGNATURE-----



More information about the R-sig-Geo mailing list