GDAL does not always come with your Python distribution.
It can sometimes be a little tricky to install.
Yopu do not need it for this class as you can always run things on the UCL Geography system via ssh
, but might like to install it, so we'll try to keep some notes up to date here on how to do that (and typical problems you encounter).
Since it relies on libraries not written in Python, you need to get these libraries installed. You may also want to install the GDAL tools.
There are many ways of doing this that you can find by searching on the internet.
A good place to start is trac.osgeo.org.
Here, we try to give some practical guidance. (Note: I've note been able to test this under windows, so give me some feedback about what works or doesn't).
There are several places you can download pre-compiled versions of the GDAL utilities from.
Oner example is http://www.kyngchaos.com/software:frameworks. If you install GDAL complete
from there, you should find the GDAL utilities in /Library/Frameworks/GDAL.framework/Programs
:
!ls /Library/Frameworks/GDAL.framework/Programs
epsg_tr.py gdal_fillnodata.py gdalchksum.py gdaltindex esri2wkt.py gdal_grid gdaldem gdaltransform gcps2vec.py gdal_merge.py gdalenhance gdalwarp gcps2wld.py gdal_polygonize.py gdalident.py mkgraticule.py gdal-config gdal_proximity.py gdalimport.py nearblack gdal2tiles.py gdal_rasterize gdalinfo ogr2ogr gdal2xyz.py gdal_retile.py gdallocationinfo ogrinfo gdal_auth.py gdal_sieve.py gdalmanage ogrtindex gdal_calc.py gdal_translate gdalmove.py pct2rgb.py gdal_contour gdaladdo gdalserver rgb2pct.py gdal_edit.py gdalbuildvrt gdalsrsinfo testepsg
If you want this in your path, put the following line at the bottom of the file ~/.bashrc
(if using bash
):
export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
or, if using tcsh
or csh
, puth this at the end of your file ~/.cshrc
:
setenv PATH "/Library/Frameworks/GDAL.framework/Programs:${PATH}"
or
set path = (/Library/Frameworks/GDAL.framework/Programs $path)
and then type:
source ~/.bashrc
or
source ~/.cshrc
as appropriate (or open new shells).
You can test that you can access the gdal commands with e.g.:
!which gdalinfo
!gdalinfo --version
/Library/Frameworks/GDAL.framework/Programs/gdalinfo GDAL 1.10.1, released 2013/08/26
homebrew
)¶If you want to compile GDAL
yourself for OS X, it is probably easiest to install the Homebrew software, type:
rehash
at the unix prompt (to update your path) and follow any instructions it gives you to sort out any conflicts you might have, then simply:
brew install gdal