Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
rgdal installation on OS X
install_from_source <- function (pkg, args = NULL, repos = "http://cran.rstudio.com", overwrite = FALSE, ...) {
if (!overwrite) {
if (pkg %in% installed.packages()) {
message(pkg, " is already installed")
return()
}
}
install.packages(
pkg,
configure.args = args,
repos = repos,
type = "source",
keep_outputs = TRUE,
verbose = TRUE)
}
usr_local_path <- function (...) file.path("/usr/local", ...)
homebrew_path <- function (...) usr_local_path("opt", ...)
stopifnot(dir.exists(homebrew_path()))
HOST_GUESS <- system("/usr/local/share/automake-1.15/config.guess", intern = TRUE)
message("HOST_GUESS is: ", HOST_GUESS)
########################################################################################
GDAL_CONFIG <- homebrew_path("gdal2", "bin", "gdal-config")
stopifnot(file.exists(GDAL_CONFIG))
PROJ_CONFIG_ARGS <- c(
paste0("--with-proj-include=", homebrew_path("proj", "include")),
paste0("--with-proj-share=", homebrew_path("proj", "share", "proj")),
paste0("--with-proj-lib=", homebrew_path("proj", "lib")))
RGDAL_CONFIG_ARGS <- c(
PROJ_CONFIG_ARGS,
#paste0("--host=", HOST_GUESS),
paste0("--with-gdal-config=", GDAL_CONFIG))
install_from_source("rgdal", args = RGDAL_CONFIG_ARGS, overwrite = TRUE)
########################################################################################
RGEOS_CONFIG_ARGS <- c(
paste0("--with-geos-config=", usr_local_path("bin", "geos-config")),
PROJ_CONFIG_ARGS)
install_from_source("rgeos", args = RGEOS_CONFIG_ARGS, overwrite = TRUE)
########################################################################################
SF_CONFIG_ARGS <- RGDAL_CONFIG_ARGS
install_from_source("sf", args = SF_CONFIG_ARGS, overwrite = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment