Since Python's matplotlib package cannot directly draw a map of China, it needs to be drawn using the BASEMAP toolkit, so the first step is to build the environment
Download the following toolkit:
Install the following toolkit to avoid VC + + errors
1.pyproj-1.9.5.1-cp36-cp36m-win_amd64.whl
Install drawing tools (measured by latitude)
2.basemap-1.1.0-cp36-cp36m-win_amd64.whl
Test installation is correct
Import time
start = Time.clock () from
mpl_toolkits.basemap import basemap
import Matplotlib.pyplot as plt< C3/>from matplotlib.patches Import Polygon
fig = plt.figure ()
ax1 = Fig.add_axes ([0.1,0.1,0.8,0.8])
map = Basemap (llcrnrlon=80.33,
llcrnrlat=3.01,
urcrnrlon=138.16,
urcrnrlat=56.123,
resolution= ' h ', Projection= ' Cass ', lat_0 = 42.5,lon_0=120,ax=ax1)
shp_info = Map.readshapefile ("chn_adm_shp\\chn_adm1", ' States ', drawbounds=true)
for info, shp in zip (Map.states_info, map.states):
proid = info[' Name_1 '] # You can open the Chn_adm1.csv file in Notepad to know that ' name_1 ' represents the name of each province
if proid = = ' Guangdong ':
poly = Polygon (shp,facecolor= ' G '), Edgecolor= ' C ', lw=3) # Drawing of the Guangdong Province region
Ax1.add_patch (poly)
map.shadedrelief () # Draw a gloomy embossed figure
map.drawcoastlines ( )
End=time.clock ()
print (End-start)
plt.show ()