How to add political boundaries for countries, states, and provinces

We can also add political boundaries, such as the divisions between nations and states:

  1. 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:

  1. 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.

  1. 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset