1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > python绘制地理分布图 使用python和matplotlib中的线条绘制地理数据图/地图

python绘制地理分布图 使用python和matplotlib中的线条绘制地理数据图/地图

时间:2023-09-04 09:26:52

相关推荐

python绘制地理分布图 使用python和matplotlib中的线条绘制地理数据图/地图

我想这就是你想要的——在三维坐标轴上画出等距线。我已经在评论中解释了每个部分的作用import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D

import numpy as np

import itertools

#read in data from csv organised in columns labelled 'lat','lon','elevation'

data = np.recfromcsv('elevation-sample.csv', delimiter=',')

# create a 3d axis on a figure

fig = plt.figure()

ax = fig.add_subplot(111, projection='3d')

# Find unique (i.e. constant) latitude points

id_list = np.unique(data['lat'])

# stride is how many lines to miss. set to 1 to get every line

# higher to miss more

stride = 5

# Extract each line from the dataset and plot it on the axes

for id in id_list[::stride]:

this_line_data = data[np.where(data['lat'] == id)]

lat,lon,ele = zip(*this_line_data)

ax.plot(lon,lat,ele, color='black')

# set the viewpoint so we're looking straight at the longitude (x) axis

ax.view_init(elev=45., azim=90)

ax.set_xlabel('Longitude')

ax.set_ylabel('Latitude')

ax.set_zlabel('Elevation')

ax.set_zlim([0,1500])

plt.show()

我用来测试的数据集不是我的,但我在github here上找到了它。在

输出如下:

注意-如果我误解了你草图中的坐标轴标签,你可以交换经纬度。在

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。