This repository contains materials for the tutorial Using Geospatial Data With Python to be held Jun 25, 2013, at the SciPy 2013 conference.
- pyproj python interface to PROJ.4 library
- Basemap plot on map projections using matplotlib
- gdal python bindings for Geospatial Data Abstraction Library (and OGR)
- shapely pythonic library for geometric tasks
- fiona pythonic interface to OGR data formats
- Cartopy Advanced mapping interface for python
- Descartes Create matplotlib Patch objects from Shapely geometries
- geoJSON reference implementation of the Python geo interface
- psycopg2 for connection to PostgreSQL/PostGIS database
- SQLAlchemy Object Relational Model for SQL databases
The standard scientific python stack is a prerequisite for this tutorial before installing the specific packages listed above. I recommend starting with a standard scientific python distribution such as Enthought Canopy or anaconda. All students for SciPy tutorials will have received a free license for Canopy for a limited period of time (also free for academic use, and anyone can use the free Canopy Express). Other package managers such as Linux distribution tools or homebrew for OS X will work for a starting point as well, though I have not tested these. On Windows you may be able to use Christoph Golke's binary packages.
Install the above packages via your standard package manager when possible. For packages not available in this way (or if you wish to use a different version than available), you may install directly with pip or easy_install. For example, to install Shapely, you may use:
pip install shapely
Finally, if all else fails, or you wish to be on the bleeding edge, you may install packages from source. For example:
git clone https://github.com/Toblerity/Shapely cd Shapely python setup.py install
will install the current development version of Shapely.
Serge Ray has shared his setup notes for OS X 10.8.4 and anaconda.
Importing shapely in Canopy version 1.0.1 on OS X fails while loading the GEOS library, and throws an exception of the form "OSError: Could not find library c or load any of its variants". This can be fixed by upgrading to Canopy 1.0.3 (available soon) or worked around by setting the following environment variable:
export DYLD_FALLBACK_LIBRARY_PATH=$(HOME)/lib:/usr/local/lib:/lib:/usr/lib
The GDAL 1.9.0 package in Canopy fails to find the PROJ.4 library for some operations. It should work for other use cases.
GDAL binary libraries may not be found even when they are installed, particularly when installing fiona. The fiona install process uses the command gdal-config --cflags to find header files. This should match your GDAL install location.
You may need to install GDAL on your system. A number of binaries are available, or you could use a package manager such as fink or apt-get, or build it from source.
- Dependency errors installing psycopg2 in Canopy and EPD. This may be overcome by downloading the psycopg2 .egg file from the Enthought PyPI mirror and installing it manually with the egginst command, or with pip install psycopg2. Windows users can try this binary installer for psycopg2 which has been reported to work.