Python given latitude and longitude marked on the map implementation

Today small for everyone to share a given Python implementation of latitude and longitude marked on the map, have a good reference value, we want to help. Come and see, to follow the small series together
bloggers recently discovered a python in a fun package called basemap, use this package you can draw a map. It is worth to say about that, basemap yet pip retrieval, and therefore can not be used directly pip install basemap, to install this package. Therefore, the following two packages themselves need to download, install and use pip in the directory.

pyproj-1.9.5.1-cp36-cp36m-win_amd64.whl
basemap-1.1.0-cp36-cp36m-win_amd64.whl

First previous renderings, you can find this toolkit is still very strong, marked out under the following describes how the latitude and longitude of the location on the map. Here Insert Picture Description
Paint the whole process is divided into two parts, the first is to draw a map of the world, as follows:

from mpl_toolkits.basemap import Basemap
  
m = Basemap()     # 实例化一个map
m.drawcoastlines()  # 画海岸线
m.drawmapboundary(fill_color='white')  
m.fillcontinents(color='white',lake_color='white') # 画大洲,颜色填充为白色
  
parallels = np.arange(-90., 90., 10.)  # 这两行画纬度,范围为[-90,90]间隔为10
m.drawparallels(parallels,labels=[False, True, True, False])
meridians = np.arange(-180., 180., 20.)  # 这两行画经度,范围为[-180,180]间隔为10
m.drawmeridians(meridians,labels=[True, False, False, True])

The second part is marked out places where the latitude and longitude, which is simpler than the part of the first step, directly Scatter () method can be used, the code is as follows:

lon, lat = m(lon, lat)  # lon, lat为给定的经纬度,可以使单个的,也可以是列表
m.scatter(lon, lat, s=100)# 标注出所在的点,s为点的大小,还可以选择点的性状和颜色等属性
plt.show()

I write to you, for everyone to recommend a very wide python learning resource gathering, click to enter , there is a senior programmer before learning to share

Experience, study notes, there is a chance of business experience, and for everyone to carefully organize a python to combat zero-based item of information,

Python day to you on the latest technology, prospects, learning to leave a message of small details

Published 57 original articles · won praise 25 · views 70000 +

Guess you like

Origin blog.csdn.net/haoxun11/article/details/105129250