How to add coastline and water features

We will begin by drawing coastlines using the following code:

# Just coastlines
m = Basemap(projection='ortho',lon_0=-114, lat_0=51)
m.drawcoastlines()
plt.show()

In the previous sections, we have seen that basemap can generate a sort of background image of coastlines of the globe, but we haven't seen how this is done. It is done simply by using the coastlines method in the preceding snippet. Using this gives us the coastlines, as shown in the following output:

In our preceding output, we see that the coastlines are fairly coarse. We can change how coarse the coastlines are by using the resolution keyword argument. By default, the resolution is set to the lowest value. We can change the coarseness to low, intermediate, or high. Here, we'll change the coarseness to low, as shown in the following code:

# Resolution
m = Basemap(projection='ortho',lon_0=-114, lat_0=51, resolution='l')
m.drawcoastlines()
plt.show()

We see that there is an increase in the resolution, as the coastlines become much finer and we actually start to see some features that are basically small lakes that were invisible before. The Hawaiian Islands, which present at the bottom-left of the map can be seen in higher resolution, and you can actually make out the individual islands in Hawaii, whereas previously, only the big island was visible.

So, in order to create a very high resolution plot that includes accurate coastlines and features, and so on, increase the resolution keyword argument.

The output for intermediate coarseness and high coarseness takes a while to load, as it involves plotting a higher resolution version of the coastlines.

It is recommended that you change the coarseness to the lowest resolution during the exploratory phase of your data analysis.
..................Content has been hidden....................

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