In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use Python to realize the map of China". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use Python to realize the map of China".
The code is as follows:
Import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemapimport cmapsimport shapefilefrom matplotlib.path import Pathfrom matplotlib.patches import PathPatch
Ny = grid_z.shape [0] nx = grid_z.shape [1] fig=plt.figure (figsize= (16par 9)) plt.rc ('font',size=15,weight='bold') ax=fig.add_subplot (111) plt.title (upright rmseqtmax012) 24hr weightweights mp=Basemap (llcrnrlon=73.,llcrnrlat=15.,urcrnrlon=136.,urcrnrlat=55,projection='cyl') CHN='G:\\ DATA\\ MAP\\ china-shapefiles-master\\' mp.readshapefile (CHN+'china','china' Drawbounds=True) sf = shapefile.Reader (CHN+'china_country') for shape_rec in sf.shapeRecords (): if shape_rec.record [8] = 'CHN': vertices = [] codes = [] pts = shape_rec.shape.points prt = list (shape_rec.shape.parts) + [len (pts)] for i in range (len (prt)-1): for j in range (PRT [I] Prt [iTun1]): vertices.append ((pts [j] [0], pts [j] [1])) codes + = [Path.MOVETO] codes + = [Path.LINETO] * (prt [iTun1]-prt [I]-2) codes + = [Path.CLOSEPOLY] clip = Path (vertices, codes) clip = PathPatch (clip, transform=ax.transData) levels=np.linspace Lats = mp.makegrid (nx, ny) # get lat/lons of ny by nx evenly space grid.x, y = mp (lons, lats) cf=mp.contourf 0.25plt.axes ([bottom, left, width, height]) mf=Basemap (llcrnrlon=107.,llcrnrlat=2.,urcrnrlon=122.,urcrnrlat=22,projection='cyl') CHN='G:\\ DATA\\ MAP\\ china-shapefiles-master\\ 'mf.readshapefile (CHN+'china','china',drawbounds=True) CHN='G:\\ DATA\\ MAP\\ china-shapefiles-master\' mf.readshapefile (CHN+'china_nine_dotted_line','china_nine_dotted_line',drawbounds=True Linewidth=1.5) mf.drawcoastlines () plt.show ()
The effect of drawing is as follows:
Thank you for your reading, the above is the content of "how to use Python to realize the map of China". After the study of this article, I believe you have a deeper understanding of how to use Python to achieve the map of China, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.