2

I have GDAL installed through QGIS and OSGeo in the directories:

C:\Program Files\QGIS 3.6\bin\gdalinfo.exe
C:\OSGeo4W64\bin\gdalinfo.exe

My gdalUtils package uses GDAL installed in QGIS and I want it to use GDAL in OSGeo because I have some troubles with QGIS's GDAL.

I set the GDAL path to OSGeo's GDAL using following code:

library(gdalUtils)
# following command forces 'gdalUtils' to use GDAL installed in OSGeo
gdal_setInstallation("C:\\OSGeo4W64\\bin", rescan = TRUE)

All troubles were gone but it was temporary. After quitting R session, when I restarted R, the same thing was all over again. How can I make gdalUtils package in R to permanently use GDAL installed in OSGeo?

1

You could modify your .Rprofile.

Easiest way is using package "usethis":

library(usethis)
edit_r_profile()

This will open your current .Rprofile. You can then add a line to the file such as:

gdalUtils::gdal_setInstallation("C:\\OSGeo4W64\\bin")

and save the file.

The gdal_setInstallation function should be then called automatically every time you start R.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.