GDAL is a useful command line tool to process spatial data. Here is a quick tutorial on how to install and get it running using Terminal on a Mac.

 

This tutorial covers how to install GDAL on a Mac, if you are interested in getting GDAL running on a Windows PC please go here (http://sandbox.idre.ucla.edu/?p=1152).

 

Step 1: Install

The following website provides the links to download the binary files for Unix/Mac platforms:

http://www.kyngchaos.com/software:frameworks

The one that I used was the link to:

GDAL 1.10 Complete [36.7 MiB] 2014-3-2

Step 2: Running GDAL

Once installed, launch a terminal window.  First, run the following command:

export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH

Alternatively, run the following to save it to your profile:

echo 'export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH' >> ~/.bash_profile
source ~/.bash_profile

The path above may be different depending on your Mac settings.  This allows the terminal window to find the gdal commands.

You should now be ready to go. To test your installation, run the Terminal command

gdalinfo --version

Step 3: Convert a shapefile to KML

An example of a gdal command may be to convert a shapefile to KML.  Navigate to the folder that has the shapefile you want to convert, and input the following command:

ogr2ogr -f "KML" sup_dist_2011.kml sup_dist_2011.shp