Python Painting China Map Environment (BASEMAP) __python

Source: Internet
Author: User

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 ()





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.