Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install and use basemap on Google Colab?

I'm using google Colab notebook for a project that requires me to plot GPS coordinates on a map. I want to use basemap for this purpose. I tried to import it on the Colab notebook by using
from mpl_tools.basemap import Basemap and it showed up the following error:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-24-2cb85a2f9bb7> in <module>()
----> 1 from mpl_tools.basemap import Basemap

ModuleNotFoundError: No module named 'mpl_tools'

I need to install the basemap module in order to use it. I tried !pip install basemap and tried to run it on Colab and that did not work.

like image 338
Suraj S Jain Avatar asked Feb 10 '19 06:02

Suraj S Jain


1 Answers

!apt-get install libgeos-3.5.0
!apt-get install libgeos-dev
!pip install https://github.com/matplotlib/basemap/archive/master.zip

There is a problem with pyproj 2.0.1, so we need to downgrade it:

!pip install pyproj==1.9.6

restart runtime

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
%matplotlib inline

This works for me on Colab on April 7, 2019. I can now set up and plot maps.

like image 84
pr3sidentspence Avatar answered Sep 21 '22 02:09

pr3sidentspence