当前位置:网站首页>Basemap库绘制地图
Basemap库绘制地图
2022-04-23 05:46:00 【今天学习要很快乐鸭】
Basemap 学习
api手册
https://matplotlib.org/basemap/api/basemap_api.html
安装basemap库
首先安装geos库
pip install geos
然后安装basemap库,在以下网站安装basemap的whl文件(注意版本)
https://www.lfd.uci.edu/~gohlke/pythonlibs/#basemap
然后用pip命令安装后,即可使用
绘制地图
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import numpy as np
#创建一个地理点的list
long=[113.8,114,114.5,113.7,114.8,114]
lat=[30,31.2,30,30.5,31,30.5]
gridid=[1,2,3,4,5,6]
count=[10,5,1,22,4,30]
#绘制底图
map = Basemap(llcrnrlon="113.6",llcrnrlat="29.971819",urcrnrlon="115.2",urcrnrlat="31.362913",\
resolution='h',projection='aea',\
lat_1=25,lat_2=47,lon_0=105,lat_0=30)
#加载矢量底图
filepath = r"E:\code\test5\wuhan.shp"
file = map.readshapefile(filepath[:-4],"Shp",default_encoding='gbk',color="#3641e5")
#绘制点
x, y = map(long, lat)
pointsize = (count-np.min(count)/(np.max(count)-np.min(count)))*10 # 计算每个点的大小
map.scatter(x, y, marker='o',c=range(len(gridid)),s=pointsize)
for a,b,c in zip(x,y,count):
plt.text(a,b,c,ha='left', fontsize=10)
plt.xlabel('longitude')
plt.ylabel('latitude')
plt.title('wuhan people')
plt.show()
#plt.savefig('wuhanpeople.jpg', dpi=120)
结果图
版权声明
本文为[今天学习要很快乐鸭]所创,转载请带上原文链接,感谢
https://blog.csdn.net/ShirleyLGY/article/details/119799001
边栏推荐
- 檢測技術與原理
- Use of multithreaded executors
- Definition of C class and method
- The onnx model of yolov5 removes the transfer layer
- 12. Monkeys climb mountains
- 程序設計訓練
- [transfer] MySQL: how many rows of data can InnoDB store in a B + tree?
- Solution to the trial of ycu Blue Bridge Cup programming competition in 2021
- H. Are You Safe? Convex hull naked problem
- Rust:如何 match 匹配 String 字符串?
猜你喜欢
Framework analysis 1 Introduction to system architecture
St table template
[leetcode 54] spiral matrix
检测技术与原理
How SYSTEMd uses / etc / init D script
Mysql database foundation
Techniques et principes de détection
Addition, deletion, modification and query of MySQL table
[leetcode 67] sum of two binary numbers
Addition, deletion, query and modification of data
随机推荐
9.Life, the Universe, and Everything
几行代码教你爬取LOL皮肤图片
Motor and drive (Qi Jinqing Edition)
Cf1427c the hard work of paparazzi
Techniques et principes de détection
渔网道路密度计算
Generation of verification code
D. Optimal partition segment tree optimization DP
[leetcode217] there are duplicate elements
用二进制进行权限管理
线程和进程的关系和区别是什么
基于pygame库编写的五子棋游戏
NVIDIA Jetson: GStreamer 和 openMAX(gst-omx) 插件
Advanced operation of idea debug
Type conversion in C #
P1018 maximum product solution
GNU EFI header file
xlsxwriter.exceptions.FileCreateError: [Errno 13] Permission denied问题
Common sense of thread pool
[leetcode 150] evaluation of inverse Polish expression