1

I am trying to use a recent feature in the mapview package that requires a driver (fgb) available in the latest GDAL version (GDAL >= 3.1.0). On my Windows machine I run

gdalinfo --version
GDAL 3.1.2, released 2020/07/07

but my rgdal (version 1.5-16) uses

> rgdal::getGDALVersionInfo()
[1] "GDAL 3.0.4, released 2020/01/28"

So how can I update the GDAL version used inside R and link it to my r-spatial packages?

mapman
  • 46
  • 4
  • Does this answer your question? [How to update a package in R?](https://stackoverflow.com/questions/21461649/how-to-update-a-package-in-r) – hmhensen Aug 21 '20 at 08:49
  • You just need to update the package. There's no "linking" packages. The function called will be loaded from the most recent version installed. – hmhensen Aug 21 '20 at 08:52
  • 1
    have you tried leveraging the [`gdal_setInstallation`](https://www.rdocumentation.org/packages/gdalUtils/versions/2.0.3.2/topics/gdal_setInstallation) function from `gdalUtils` package? – alex_jwb90 Aug 21 '20 at 08:52
  • @hmhensen thanks for your swift response. no, the post did not help, sorry. @alex_jwb90 I used `gdal_setInstallation()` with `rescan=TRUE` and it found the desired version. However, `rgdal::getGDALVersionInfo()` still gives me the older version, even if I remove and reinstall `rgdal`. Anything else I could be missing? – mapman Aug 21 '20 at 09:41
  • 1
    On windows (and mac), if you install packages via CRAN binaries, you will get the system libs that were included statically at build time of the binary that you download. In order to link to a different GDAL version, you need to install packages from source and potentially set some compilation flags. I'd advise to only do that if you know what you are doing... – TimSalabim Aug 21 '20 at 13:04
  • I have the same request. I deleted `rgdal` and `sp` and installed the newest versions and it did update `GDAL` from `rgdal::getGDALVersionInfo(str = "--version") # "GDAL 2.2.3, released 2017/11/20"` to `"GDAL 3.0.4, released 2020/01/28"` but it didn't update to newest version. I think rather than install from source as @TimSalabim suggests, `rgdal` will require to work from the newer version on a future release and will automatically update when you install then – user63230 Aug 24 '20 at 14:59
  • 2
    As I said, if you `install.packages()` you get the GDAL version that the binary was linked to at build time (which for windows currently is 3.0.4). So either wait until the windows binary builds ship with a newer version (not sure when) or compile from source and set flags where to find the specific GDAL on your computer that you want it to be linked against. Or switch to Linux, install the latest GDAL and `installpackages()` will be linked to that (as there are no binaries for Linux, i.e. always installs from source). – TimSalabim Aug 24 '20 at 15:06
  • 1
    @TimSalabim thanks. I'm going to wait for now, just thought i'd add that information in case it helps anyone! – user63230 Aug 24 '20 at 15:08
  • @TimSalabim great, thanks for the clarification! One more reason to finally make the switch to Linux. – mapman Aug 25 '20 at 15:22

0 Answers0