python实现经纬度采样的示例代码
作者:liuyu进阶 时间:2021-12-25 13:24:37
原理
经度 phi,纬度 theta 处的坐标为:
x =R* cos(phi) * cos(theta)
y = Rsin(phi) * cos(theta)
z = Rsin(theta)
问题
经纬度采样的采样点是相同经纬度间隔的交点。但是采样1000个点,如何划分多少条经线,多少条纬线相交,才能使1000个采样点最均匀的分布在球面上(虽然经纬度采样本来就不均匀,但对于不同的采样点个数应该有一种相对最均匀的经纬线划分)?求大佬指教!
我目前是将纬度每10度进行划分。
Code
import random
from mpl_toolkits import mplot3d
import numpy as np
import math
import matplotlib.pyplot as plt
%matplotlib inline
ax=plt.axes(projection="3d")
N=1000
x=[]
y=[]
z=[]
r=1
#经度
def longitude(lng):
phi=(180+lng)*(math.pi/180)
return phi
#纬度
def latitude(lat):
theta=lat*(math.pi/180)
return theta
for i in range(-80,90,10):
for j in np.arange(-180,180,360/((N-2)/17)):
#x.append(-r*math.sin(latitude(i))*math.cos(longitude(j)))
#y.append(r*math.cos(latitude(i)))
#z.append(r*math.sin(latitude(i))*math.sin(longitude(j)))
x.append(r*math.cos(latitude(i))*math.cos(longitude(j)))
z.append(r*math.sin(latitude(i)))
y.append(r*math.cos(latitude(i))*math.sin(longitude(j)))
x.append(r*math.cos(latitude(-90))*math.cos(longitude(0)))
z.append(r*math.sin(latitude(-90)))
y.append(r*math.cos(latitude(-90))*math.sin(longitude(0)))
x.append(r*math.cos(latitude(90))*math.cos(longitude(0)))
z.append(r*math.sin(latitude(90)))
y.append(r*math.cos(latitude(90))*math.sin(longitude(0)))
xline=np.array(x)
yline=np.array(y)
zline=np.array(z)
print(xline.shape)
ax.scatter3D(xline,yline,zline,s=2)
plt.savefig("D:\\samples\\经纬度采样.png")
效果
来源:https://blog.csdn.net/m0_45866718/article/details/110818735
标签:python,经纬度,采样
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
用 SA FileUp 上传多文件
2008-07-04 13:44:00
Python如何避免文件同名产生覆盖
2021-02-05 21:16:34
![](https://img.aspxhome.com/file/2023/4/85364_0s.png)
tensorflow输出权重值和偏差的方法
2021-10-01 15:56:13
用CSS制作兼容多浏览量器的隐藏菜单
2007-08-30 09:05:00
python time.strptime格式化实例详解
2022-03-25 19:13:02
SQLServer 2000 升级到 SQLServer 2008 性能之需要注意的地方之一
2012-02-25 19:44:26
ASP开发中有用的函数(function)集合(1)
2008-10-14 17:10:00
一个较新的ASP后门服务端实现代码
2011-02-16 10:41:00
python中sys模块是做什么用的
2021-04-30 10:04:48
Python的互斥锁与信号量详解
2021-12-24 15:29:34
DateDiff函数在Sql与Access中的区别
2009-06-04 18:02:00
Python实现壁纸下载与轮换
2022-07-01 19:19:19
Python异常对代码运行性能的影响实例解析
2023-10-18 23:35:39
![](https://img.aspxhome.com/file/2023/8/87488_0s.png)
ASP 生成静态新闻列表
2009-03-03 12:25:00
一个小技巧mysql命令行分页
2011-01-29 16:33:00
Python 使用多属性来进行排序
2023-11-10 21:15:07
python openvc 裁剪、剪切图片 提取图片的行和列
2022-07-03 15:29:40
![](https://img.aspxhome.com/file/2023/4/77874_0s.jpg)
详解Laravel模型事件和模型事件在Trait中的使用
2023-06-17 17:19:28
IE中雅黑字体给布局带来的变化
2008-06-13 11:22:00
![](https://img.aspxhome.com/file/UploadPic/20086/13/2008613122420492s.gif)
PDO::setAttribute讲解
2023-06-05 18:04:23