# Basemap

by Dane Miller

Here is a step by step method of using matplotlib basemap in python. Before you get started make sure you have installed matplotlib and basemap.

Matplotlib
https://matplotlib.org/

The process is a lot easier if you are using Anaconda with Jupyter notebook.
https://anaconda.org/conda-forge/matplotlib
https://anaconda.org/anaconda/basemap

Once you have successfully installed and updated all modules then we can get to the fun stuff! Mapping!!!

Basemap has a lot of features, in this post I am focusing on a couple simple features.
https://matplotlib.org/basemap/api/basemap_api.html#module-mpl_toolkits.basemap

```from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
```
```m = Basemap(projection='mill',
llcrnrlat = -90,
llcrnrlon = -180,
urcrnrlat = 90,
urcrnrlon = 180,
resolution = 'l')
```
```m.drawcoastlines()
m.drawcountries(linewidth=2)
m.drawrivers(color='blue')
m.fillcontinents(color='g', lake_color='blue', alpha=0.5)

plt.title('Basemap of the globe')
plt.show()
```

Here is our first map of the globe.

```# Lambert Conformal map of lower 48 states.
m = Basemap(llcrnrlon=-119,llcrnrlat=20,urcrnrlon=-64,urcrnrlat=49,
projection='lcc',lat_1=33,lat_2=45,lon_0=-95)

m.drawcoastlines()
m.drawcountries(linewidth=2)
m.drawrivers(color='blue')
m.fillcontinents(color='g', lake_color='blue', alpha=0.5)
m.drawstates()
# m.bluemarble()

plt.title('Basemap of the United States of America')
plt.show()
```

Map of the lower 48 states in the US. Note you can see all the states and rivers drawn out to the map. This is easily done by using m.drawrivers(color=select a color) and m.drawstates().

```# Lambert Conformal map of California
m = Basemap(width=1284000,height=1164000,projection='lcc',lat_1=30.,lat_2=60,
lat_0=37,lon_0=-120.5,resolution='h',rsphere=6370000.00)

m.drawcoastlines()
m.drawcountries(linewidth=2)
m.drawrivers(color='blue')
m.fillcontinents(color='g', lake_color='blue', alpha=0.5)
m.drawstates()
m.drawcounties()
# m.bluemarble()

plt.title('Basemap of California')
plt.show()
```

Zooming in even closer to a single state, California.

```# Lambert Conformal map of California
m = Basemap(width=1284000,height=1164000,projection='lcc',lat_1=36,lat_2=38,
lat_0=37.7749,lon_0=-122.4194,resolution='h',rsphere=63700000.00)

m.drawcoastlines()
m.drawcountries(linewidth=2)
m.drawrivers(color='blue')
m.fillcontinents(color='tan', lake_color='blue', alpha=0.5)
m.drawcounties(linewidth=1, color='black')
# m.bluemarble()

plt.title('Basemap San Francisco Bay')
plt.show()
```

And finally, zoomed into the San Francisco Bay.