Created
July 24, 2017 17:18
-
-
Save mnosshi/cb756db071bbf67db91e5dc7b085315f to your computer and use it in GitHub Desktop.
Installation Notes--MODIStsp for mac OS X (sierra), R 3.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
installing MODIStsp requires many dependencies: | |
library(RGtk2; rgdal; cairo; sp; bitops; data.table; gdalUtils; hash; gWidgets; rgeos; xts; XML; xml2; stringr; httr; RJSONIO; chron; iterators; digest; pacman; curl) | |
and for MAC OSX sierra, there are two main issues: | |
1. As outlined here in the comment by @tobybot11 (https://gist.github.com/sebkopf/9405675) Rgtk requires the x11 libraries/headers (gdk/gdkx.h specifically) | |
and doesn't work with the quartz libraries/headers which now is the default for GTK | |
2. When installing the dependencies gWidgetsRGtk2 and cairoDevice from CRAN you need to choose the version "OS X Mavericks binaries" | |
and not "Package source" | |
To start, update to the recent R package, then update packages | |
#1. update packages | |
update.packages() | |
#2. install the development version of devtools: | |
install.packages(c("devtools")) | |
devtools::install_github("hadley/devtools") | |
#3. install RGtk2 using Homebrew https://gist.github.com/sebkopf/9405675 | |
#first ensure you have cairo installed with "--with-x11": | |
# brew uninstall cairo --ignore-dependencies | |
# brew install --with-x11 cairo | |
#next edit configure options for GTK to require x11 rather than Quartz: | |
# brew edit gtk+ | |
# --with-gdktarget=x11 | |
# --enable-x11-backend | |
# brew install --build-from-source --verbose gtk+ | |
# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib/pkgconfig/gtk+-2.0.pc:/opt/X11/lib/pkgconfig | |
#next go to CRAN and download RGtk2_2.20.33.tar.gz and run: | |
# R CMD INSTALL RGtk2_2.20.33.tar.gz | |
library(RGtk2) | |
#4. install GDAL first using: brew install gdal | |
# since rgdal is not looking in /usr/local/lib must include that with install.packages(), line below | |
install.packages('rgdal', type = "source", configure.args=c('--with-proj-include=/usr/local/include','--with-proj-lib=/usr/local/lib')) | |
# check all dependencies are there | |
library(RGtk2) | |
library(rgdal) | |
library(cairo) | |
library(sp) | |
library(bitops) | |
library(data.table) | |
library(gdalUtils) | |
library(hash) | |
library(gWidgets) | |
library(rgeos) | |
library(xts) | |
library(XML) | |
library(xml2) | |
library(stringr) | |
library(httr) | |
library(RJSONIO) | |
library(chron) | |
library(iterators) | |
library(digest) | |
library(pacman) | |
library(curl) | |
#5. library(gWidgetsRGtk2) | |
#### very important !!!! in CRAN choose the version "OS X Mavericks binaries" for | |
#### gWidgetsRGtk2 and cairoDevice, not "Package source", and it will work for | |
#### R version 3.4, mac OS X Sierra. Move both to Frameworks/R.framework/3.4... and | |
#### open R and run the code below. This will also install cairoDevice | |
install.packages("gWidgetsRGtk2", lib="~/Library/Frameworks/R.framework/Versions/3.4/Resources/library/gWidgetsRGtk2") | |
library(gWidgetsRGtk2) | |
library(cairoDevice) | |
#6. install development version of MODIStsp from github | |
library(devtools) | |
install_github("lbusett/MODIStsp", ref = "master") | |
library(MODIStsp) | |
MODIStsp() | |
#gave error, when I restart R it worked! | |
#but then, I ran MODIStsp() and got this error: "Your local GDAL installation does not support HDF4 format. Please install HDF4 support and recompile GDAL." | |
# I had to unistall GDAL in brew and follow notes here (http://r-sig-geo.2731867.n2.nabble.com/OSX-rgdal-GDAL-drivers-and-HDF4-td7588400.html): | |
# > brew install hdf4 | |
# prefer hdf4 links over NetCDF | |
# > brew link --overwrite hdf4 | |
# > brew install gdal --complete --enable-unsupported --with-hdf4 | |
# check what drivers are installed, list should include hdf4: | |
# > gdal-config --formats | |
# Good luck! | |
########################################################## | |
# in case R beggins to hangup constantly | |
# these 3 lines of code remove all packadges, | |
# except base R (this solved fatal errors from happening) | |
########################################################## | |
ip <- installed.packages() | |
pkgs.to.remove <- ip[!(ip[,"Priority"] %in% c("base", "recommended")), 1] | |
sapply(pkgs.to.remove, remove.packages) | |
# this line installs them again, but you loose non-base packages | |
sapply(pkgs.to.remove, install.packages) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment