#283 Set bounding box in basemap

#283 Set bounding



Charts #281 and #282 show how to make a world map with desired colors. But what if you want to look at a specific region of the globe?

When you initialise the map, you can determine a specific region with 4 arguments. You have to provide the coordinates of 2 opposite corners of the zone.

You can use this tool to find out the latitude and longitude that you need, clicking on a map.





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

# Control the position of the square. Give the coordinate of 2 corners
m=Basemap(llcrnrlon=-100, llcrnrlat=-58,urcrnrlon=-30,urcrnrlat=15)

# Draw the components of the map
m.drawmapboundary(fill_color='#A6CAE0', linewidth=0)
m.fillcontinents(color='brown', alpha=0.6, lake_color='grey')
m.drawcoastlines(linewidth=0.1, color="white")

  • Sponsors

  • Leave a Reply

    Your email address will not be published.