Bhaskar Karambelkar's Blog

GDAL 2 On Mac with Homebrew

 

Tags: r r-stats rstats GIS


This is a small post about upgrading to gdal 2.x on a Mac using homebrew.

Assumptions

  • You have homebrew installed and setup.
  • You already have gdal 1.x installed via homebrew’s default ‘gdal’ formula.

Install gdal 2.x

  • Unlink gdal 1.x using

    brew unlink gdal
    
  • Tap into osgeo4mac

    brew tap osgeo/osgeo4mac && brew tap --repair
    
  • Install gdal 2.x

    brew install jasper netcdf # gdal dependencies
    brew install gdal2 --with-armadillo \
    --with-complete --with-libkml --with-unsupported
    
  • Link gdal 2.x

    brew link --force gdal2
    
  • Verify

    $> gdal-config --version
    2.1.1
    $> gdal-config --libs
    -L/usr/local/Cellar/gdal2/2.1.1/lib -lgdal
    $> gdal-config --cflags
    -I/usr/local/Cellar/gdal2/2.1.1/include
    

NOTE: The version number shown is the latest as of Oct 20th, 2016.

Post Install

If you are using R for geo-spatial stuff, be sure to reinstall the rgdal library. Also you can now install sf in R using …

devtools::install_github('edzer/sfr')