TPPZ
TPPZ

Reputation: 4891

How to install map/plotting libraries cartopy and basemap using pip

I understand some dependencies need to be satisfied before installing cartopy and basemap. I sorted out most of them using pip (like numpy etc.).

I found out there are some cartopy issues with Proj.4 and some basemap issues with GEOS. I thought the python bindings to the Java project Proj.4 were enough and I am a bit lost with the C++ library GEOS (I think GDAL is enough for GEOS, I've linked it to the python world this way: pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version).

I would prefer avoiding all those things like anaconda, canopy, etc. If possible I would like to use only pip on both Ubuntu (apt-get, only if pip is not enough) and Mac OSX (homebrew e.g. brew install <some_package>, only if pip is not enough).

cartopy gets stuck on a version of Proj.4 that is too old. The pip output says: Proj4 version 4.8.0 is installed, but cartopy requires at least version 4.9.0.. I was assuming this pip install of the python bindings was enough, but it does not solve the problem:

$ pip show pyproj
Name: pyproj
Version: 1.9.5.1
Summary: Python interface to PROJ.4 library
Home-page: https://github.com/jswhit/pyproj
Author: Jeff Whitaker
Author-email: [email protected]
License: OSI Approved
Location: /usr/local/lib/python2.7/dist-packages
Requires: 

I don't get why the python bindings to Proj.4 are not enough, even if those bindings are the latest version available using pip.

basemap is stuck in different ways:

I am not sure what I am doing wrong:

I am a bit confused in this no mans land between Java binaries, C++ binaries and bindings to python packages.

Upvotes: 2

Views: 4526

Answers (1)

Dawid Laszuk
Dawid Laszuk

Reputation: 1978

As you noticed cartopy requires Proj.4 lib in version >=4.9. On Ubuntu (newer than 16.04) you can install it through sudo apt-get install libproj-dev.

For older Ubuntu, e.g. 14.04, you could simply download newest package from 16.04 (xenial libproj-dev) and install it manually. Notice that it depends on libproj9 in version 4.9. Remember to remove older version before you update them with
sudo apt-get purge libproj-dev libproj9 Once you done that, open and download packages from links for appropriate architecture (from your log I understand that's amd64). Double click downloaded files in order librproj9 and libproj-dev or use sudo dpkg -i <path_to_file>.

Upvotes: 1

Related Questions