When using python Basemap to plot maps, a nice background would be a big plus. But when using map.bluemarble(), map.etopo(), or map.shadedrelief(), we can not zoom in to a smaller region, since it will generate a blur image. The best way to create a high resolution background image (either topography, street map, etc.) is using arcgisimage method. See the documentation here. I will show the following examples to plot the nice map.
For using arcgisimage method, you need specify the epsg for different region, and choose the services from the following list (see different services here, also here):
For using arcgisimage method, you need specify the epsg for different region, and choose the services from the following list (see different services here, also here):
- World_Physical_Map
- World_Shaded_Relief
- World_Topo_Map
- NatGeo_World_Map
- ESRI_Imagery_World_2D
- World_Street_Map
- World_Imagery
- ESRI_StreetMap_World_2D
- Ocean_Basemap
In [1]:
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
In [2]:
# let's first define a helper function to plot the map of Bay Area in US.
def plot_map(service = 'World_Physical_Map', epsg = 4269, xpixels = 5000):
# note, you need change the epsg for different region,
#US is 4269, and you can google the region you want
plt.figure(figsize = (8, 8))
m = Basemap(projection='mill',llcrnrlon=-123. ,llcrnrlat=37,
urcrnrlon=-121 ,urcrnrlat=39, resolution = 'l', epsg = epsg)
# xpixels controls the pixels in x direction, and if you leave ypixels
# None, it will choose ypixels based on the aspect ratio
m.arcgisimage(service=service, xpixels = xpixels, verbose= False)
plt.show()
1 - World_Physical_Map¶
In [3]:
plot_map(service = 'World_Physical_Map', epsg = 4269)
2 - World_Shaded_Relief¶
In [4]:
plot_map(service='World_Shaded_Relief')
3 - World_Topo_Map¶
In [5]:
plot_map(service='World_Topo_Map')
4 - NatGeo_World_Map¶
In [6]:
plot_map(service='NatGeo_World_Map')
5 - ESRI_Imagery_World_2D¶
In [7]:
plot_map(service='ESRI_Imagery_World_2D')
6 - World_Street_Map¶
In [8]:
plot_map(service='World_Street_Map')
7 - World_Imagery¶
In [9]:
plot_map(service='World_Imagery')
8 - ESRI_StreetMap_World_2D¶
In [10]:
plot_map(service='ESRI_StreetMap_World_2D')








