We can also add political boundaries, such as the divisions between nations and states:
- We get these boundaries by calling the m.drawcountries() function, as shown in the following code:
# Countries & states
m = Basemap(projection='ortho',lon_0=-114, lat_0=51)
m.drawcoastlines()
m.drawcountries()
plt.show()
The political boundaries can be seen in the following output:
- The political divisions within countries can also be drawn using the drawstates( ) function, as shown here:
# Countries & states
m = Basemap(projection='ortho',lon_0=-114, lat_0=51)
m.drawcoastlines()
m.drawcountries()
m.drawstates()
plt.show()
We get the 50 states of the US, the provinces and territories of Canada, as well as divisions within Mexico and other countries, as shown in the following output:
Hence, basemap actually includes everything you need to draw not only physical boundaries, but political ones as well.
- We can also add water features (rivers and lakes) using the basemap methods, along with the color of the rivers, as shown in the following code:
m = Basemap(projection='ortho',lon_0=-114, lat_0=51)
m.drawcoastlines()
m.drawrivers(color='b')
m.fillcontinents(color='none', lake_color='b')
plt.show()
We get the following output:
As seen in the preceding output, we can draw lakes, as well as rivers.