3

I would like to obtain a map of the United States so I can plot coordinates or destination lines on it. I cannot seem to find how to plot a map of the US. Is there anyway I can do this in Python?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Deepak M
  • 1,124
  • 2
  • 18
  • 28

1 Answers1

1

You can use pyplot's basemap module for things like that:

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

m = Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
            rsphere=(6378137.00,6356752.3142),\
            resolution='l',area_thresh=1000.,projection='lcc',\
            lat_1=50.,lon_0=-107.,ax=ax)

plt.show()

For more examples have a look at the basemap docu.

  • thanks, but i get the error message (ImportError:" No module named basemap"). I am running python 2.7 on windows do i need to install something for it to work? @e-dschungel – Deepak M Nov 07 '16 at 05:38
  • @DeepakM You need to [install](http://matplotlib.org/basemap/users/installing.html) the basemap module. For Windows there are binary packages. – e-dschungel Nov 07 '16 at 06:40
  • hey i got a map to work but i was having couple issues i was wondering if you could take a look and help me see whats the issue here : http://stackoverflow.com/questions/40491340/plotting-a-map-with-geopy-and-matplotlib-in-jupyter-notebook @e-dschungel – Deepak M Nov 08 '16 at 16:59