-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Python Geospatial Analysis Cookbook
By :

SciPy is a collection of Python libraries, including SciPy library, matplotlib, pandas, SymPy, and IPython. The SciPy library itself is used for many operations, but we are particularly interested in the spatial module. This module can do many things including running a nearest neighbor query.
PySAL is a geospatial computing library that's used for spatial analysis. Creating models and running simulations directly from Python code are some of the many library functions that PySAL offers. PySAL is a library that, when put together with our visualization tools such as matplotlib, gives us a great tool.
IPython is a Python interpreter for a console that replaces the normal Python console you may be used to when running and testing Python code from your terminal. This is really just an advanced interpreter with some cool features, such as Tab completion, which means that beginners can get commands quickly by typing a letter and hitting Tab. The IPython notebooks help share code in the form of a web page, including code, images, and more without any installation.
The dependency jungle we looked at earlier is back and we need three more universal installations to our Ubuntu system using apt-get install
as follows:
$ sudo apt-get install libblas-dev liblapack-dev gfortran
Windows and Mac users can use a full installer (http://www.scipy.org/install.html), such as Anaconda or Enthought Canopy, which will perform all the installation dependencies for you in one go.
Three dependencies are used for the SciPy installation. PySAL depends on SciPy so make sure to install SciPy first. Only IPython does not need any extra installations.
Start up your Python virtual environment with the following code:
mdiener@mdiener-VirtualBox:~$ workon pygeoan_cb (pygeoan_cb)mdiener@mdiener-VirtualBox:~$
Let's look at these steps:
$ pip install scipy
$ pip install pysal
(pygeoan_cb)mdiener@mdiener-VirtualBox:~$python >>> import scipy >>> import pysal >>>
$ pip install ipython
SciPy and PySAL libraries are both geared to help accomplish various spatial analysis duties. The choice of tool is based on the task at hand, so make sure that you check which library offers what function at the command prompt as follows:
>>> from scipy import spatial >>> help(spatial)
The output should look like what is shown in the following screenshot:
Change the font size
Change margin width
Change background colour