Installing pyproj and NumPy
The pyproj is a wrapper around the PROJ.4 library that works with projections and performs transformations (https://pypi.python.org/pypi/pyproj/) in Python. All your geographic information should be projected into one of the many coordinate systems supported by the European Petroleum Survey Group (EPSG). This information is necessary for the systems to correctly place data at the appropriate location on Earth. The geographic data can then be placed on top of each other as layers upon layers of data in order to create maps or perform analysis. The data must be correctly positioned or we won't be able to add, combine, or compare it to other data sources spatially.
Data comes from many sources and, often, a projection is not the same as a dataset. Even worse, the data could be delivered with a description from a data provider stating it's in projection UTM31 when, in reality, the data is in projection UTM34! This can lead to big problems later on when trying to get your data to work together as programs will throw you some ugly error messages.
NumPy is the scientific backbone of number crunching arrays and complex numbers that are used to power several popular geospatial libraries including GDAL (geospatial abstraction library). The power of NumPy lies is in its support for large matrices, arrays, and math functions. The installation of NumPy is, therefore, necessary for the other libraries to function smoothly, but is seldom used directly in our quest for spatial analysis.
Getting ready
Fire up your virtual environment, if it is not already running, using the following standard start command:
$ workon pygeoan_cb
Your prompt should now look like this:
(pygeoan_cb)mdiener@mdiener-VirtualBox:~$
Note
If workon
for some reason does not start your virtual environment, you can start it simply by executing source /home/mdiener/venvs/pygeoan_cb/bin/activate
from the command line; try the steps listed in the Installing virtualenv and virtualenvwrapper recipe again to get it going.
Now, we need to install some Python tools for development that allow us to install NumPy, so run this command:
$ sudo apt-get install -y python-dev
You are now ready to move on and install pyproj and NumPy inside your running virtual environment.
How to do it...
Simply fire up virtualenv
and we will use the pip installer to do all the heavy lifting as follows:
- Use pip to go ahead and install NumPy; this can take a couple of minutes as many lines of installation verbosity are written on screen:
$ pip install numpy
Windows users can grab the
.whl
file for NumPy and execute it using following command:pip install numpy -1.9.2+mkl-cp27-none-win32.whl
- Use
pip
one more time to install pyproj:$ pip install pyproj
Windows users can use the following command to install pyproj:
pip install pyproj-1.9.4-cp27-none-win_amd64.whl
- Wait a few minutes; NumPy should be now running along with pyproj. To test if it's worked out, enter the following command in the Python console. The output should look like this:
(pygeoan_cb)mdiener@mdiener-VirtualBox:~/venv$ python Python 2.7.3 (default, Feb 27 2014, 19:58:35) [GCC 4.6.3] on linux2 Type “help”, “copyright”, “credits”, or “license” for more information. >> import numpy >> import pyproj
No errors, I hope. You have now successfully installed NumPy and pyproj.
Note
All sorts of errors could show up, so please take a look at the respective installation links to help you solve them:
For pyproj: https://pypi.python.org/pypi/pyproj/
For NumPy: http://www.numpy.org
How it works...
This easy installation works using the standard pip installation method. No tricks or special commands are needed. You need to simply execute the pip install <library_name>
command and you are off to the races.
Tip
Library names can be found by visiting the https://pypi.python.org/pypi web page if you are unsure of the exact name you want to install.