A terrible Mac incident required me to reformat my Mac and reinstall everything from scratch to do desktop GIS. This is also an opportunity to standardize everything on Homebrew. The advantage to this is that all your tools are drawn from the same stack and relate to each other, in addition to being easily updatable and jointly so.
So, how to get this otherwise wonderful machine ready to do desktop GIS work? Here we go…
Install iTerm2
This gives you a better terminal.
Install Dotfiles Repository
This gives you a big collection of configurations right out of the box, but you need to do a little work.
https://github.com/atomantic/dotfiles
cd ~
git clone https://github.com/atomantic/dotfiles .dotfiles
git submodule update --init --recursive
Install Homebrew
This gives you the package management system.
Python
You will need both Python 2 and Python 3 for certain GIS technologies, so install them both.
brew install python2 python3
Because Homebrew installs Python in a very goofy way, you will need to create a symbolic link to the Python of your choice, be it p2 or p3. I opt for P2.
sudo ln -s /usr/local/bin/python2 /usr/local/bin/python
You will also want to install virtualenvwrapper
pip2 install virtualenvwrapper
export WORKON_HOME=~/Envs mkdir -p $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh
Edits to your ‘.zshrc’ will have to be made, please see the enclosed example for this.
PostGIS
brew install postgis
This will get a whole lot of dependencies for you that you will need for other GIS software, and you’re going to want to build everything with PSQL and PostGIS support, so install this first.
G.R.A.S.S.
https://grasswiki.osgeo.org/wiki/Compiling_on_MacOSX_using_homebrew
brew tap osgeo/osgeo4mac brew install netcdf brew install gdal2 --with-complete --with-unsupported --with-postgresql export GDAL_DATA=/usr/local/opt/gdal2/share/gdal/ # Also add the above line to ~/.bash_profile, ~/.bashrc, or some other login script brew install grass-70 --with-netcdf --with-postgresql brew install gdal2-grass7
GDAL 2
GDAL 2 is the one that will give you quite a bit of headache till you realise that you can take care of it in Homebrew. Install others first though.
https://www.karambelkar.info/2016/10/gdal-2-on-mac-with-homebrew/
Docker
Install Docker the normal way and then move the storage to an external location by this method.
QGIS
This one is tricky because you will need to install packages to both your p2 and p3.
pip2 install numpy scipy matplotlib processing psycopg2
pip3 install numpy scipy matplotlib psycopg2
pip3 install requests future jinja2 pygments
Then use Homebrew to install it and link to the Apps
brew install qgis2
brew linkapps qgis2
Fonts
Now comes the terrible part. You will need a whole lot of fonts for GRASS and QGIS to work correctly. And this will tie up your Homebrew forever, because Homebrew can only run one process at a time. You can’t have _n_ terminals running _n_ instances of Homebrew.
First install these: https://github.com/powerline/fonts
mkdir -p ~/.config/fontconfig/conf.d ; cd ~/.config/fontconfig/conf.d/
cp ~/source/fonts/fontconfig/50-enable-terminess-powerline.conf ./
sudo fc-cache -vf
Then install the Google Noto fonts: https://www.google.com/get/noto/help/install/
Then use the Bazooka to get everything that’s missing:
brew tap caskroom/fonts /bin/zsh -c 'print -l "$(brew --repo caskroom/fonts)"/Casks/*(:t:r) | xargs brew cask install'
R
Next you will need to install R.
brew tap homebrew/science
brew install Caskroom/cask/xquartz
brew install r
.zshrc
# Path to your oh-my-zsh configuration. export ZSH=$HOME/.dotfiles/oh-my-zsh # if you want to use this, change your non-ascii font to Droid Sans Mono for Awesome # POWERLEVEL9K_MODE='awesome-patched' export ZSH_THEME="powerlevel9k/powerlevel9k" POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 # https://github.com/bhilburn/powerlevel9k#customizing-prompt-segments # https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir nvm vcs) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status history time) # colorcode test # for code ({000..255}) print -P -- "$code: %F{$code}This is how your text would look like%f" POWERLEVEL9K_NVM_FOREGROUND='000' POWERLEVEL9K_NVM_BACKGROUND='072' POWERLEVEL9K_SHOW_CHANGESET=true #export ZSH_THEME="random" # Set to this to use case-sensitive completion export CASE_SENSITIVE="true" # disable weekly auto-update checks # export DISABLE_AUTO_UPDATE="true" # disable colors in ls # export DISABLE_LS_COLORS="true" # disable autosetting terminal title. export DISABLE_AUTO_TITLE="true" # Which plugins would you like to load? (plugins can be found in ~/.dotfiles/oh-my-zsh/plugins/*) # Example format: plugins=(rails git textmate ruby lighthouse) plugins=(colorize compleat dirpersist autojump git gulp history cp virtualenvwrapper python) source $ZSH/oh-my-zsh.sh test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" source /usr/local/opt/nvm/nvm.sh autoload -U add-zsh-hook load-nvmrc() { if [[ -f .nvmrc && -r .nvmrc ]]; then nvm use &> /dev/null elif [[ $(nvm version) != $(nvm version default) ]]; then nvm use default &> /dev/null fi } add-zsh-hook chpwd load-nvmrc load-nvmrc # Customize to your needs... unsetopt correct # run fortune on new terminal :) fortune # ZSh Config things alias zshconfig="atom ~/.zshrc" ## Python things export PATH="/usr/local/bin:$PATH" export WORKON_HOME=~/Envs export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python ## GDAL things export GDAL_DRIVER_PATH=/usr/local/lib/gdalplugins export GDAL_DATA=/usr/local/opt/gdal2/share/gdal/ export PATH="/usr/local/opt/gdal2/bin:$PATH" # GRASS things export GRASS_PYTHON=/System/Library/Frameworks/Python.framework/Versions/Current/bin/pythonw