python实现经纬度采样的示例代码


Posted in Python onDecember 10, 2020

原理

经度 phi,纬度 theta 处的坐标为:
x =R* cos(phi) * cos(theta)
y = Rsin(phi) * cos(theta)
z = R
sin(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")

效果

python实现经纬度采样的示例代码

到此这篇关于python实现经纬度采样的示例代码的文章就介绍到这了,更多相关python 经纬度采样内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Python 相关文章推荐
跟老齐学Python之从格式化表达式到方法
Sep 28 Python
Python爬取读者并制作成PDF
Mar 10 Python
python根据时间生成mongodb的ObjectId的方法
Mar 13 Python
python使用Queue在多个子进程间交换数据的方法
Apr 18 Python
深入浅析Python字符编码
Nov 12 Python
通过cmd进入python的实例操作
Jun 26 Python
Python Django中间件,中间件函数,全局异常处理操作示例
Nov 08 Python
使用遗传算法求二元函数的最小值
Feb 11 Python
Python enumerate内置库用法解析
Feb 24 Python
Python itertools.product方法代码实例
Mar 27 Python
在Python中字典按值排序的实现方法
Nov 12 Python
python 获取计算机的网卡信息
Feb 18 Python
Python urlopen()参数代码示例解析
Dec 10 #Python
Python urllib request模块发送请求实现过程解析
Dec 10 #Python
Python APScheduler执行使用方法详解
Dec 10 #Python
flask项目集成swagger的方法
Dec 09 #Python
python的dict判断key是否存在的方法
Dec 09 #Python
python RSA加密的示例
Dec 09 #Python
python中把元组转换为namedtuple方法
Dec 09 #Python
You might like
Zend Guard一些常见问题解答
2008/09/11 PHP
常见的PHP五种设计模式小结
2011/03/23 PHP
php+html5实现无刷新图片上传教程
2016/01/22 PHP
php无限级分类实现方法分析
2016/10/19 PHP
php实现有序数组打印或排序的方法【附Python、C及Go语言实现代码】
2016/11/10 PHP
ThinkPHP5.1的权限控制怎么写?分享一个AUTH权限控制
2021/03/09 PHP
prototype 1.5相关知识及他人笔记
2006/12/16 Javascript
jquery异步跨域访问代码
2013/06/28 Javascript
javascript类型转换示例
2014/04/29 Javascript
jquery悬浮提示框完整实例
2016/01/13 Javascript
jQuery限制图片大小的方法
2016/05/25 Javascript
分享javascript实现的冒泡排序代码并优化
2016/06/05 Javascript
jQuery实现调整表格单列顺序完整实例
2016/06/20 Javascript
详解Angular cli配置过程记录
2019/11/07 Javascript
[50:28]LGD女子学院第三期 DOTA2复仇之魂教学
2013/12/24 DOTA
[00:20]DOTA2荣耀之路7:-ah fu-抢盾
2018/05/31 DOTA
Python内置函数bin() oct()等实现进制转换
2012/12/30 Python
python通过邮件服务器端口发送邮件的方法
2015/04/30 Python
浅析Python中的多条件排序实现
2016/06/07 Python
详解supervisor使用教程
2017/11/21 Python
python 用lambda函数替换for循环的方法
2018/06/09 Python
解决python通过cx_Oracle模块连接Oracle乱码的问题
2018/10/18 Python
python实现布隆过滤器及原理解析
2019/12/08 Python
python 中值滤波,椒盐去噪,图片增强实例
2019/12/18 Python
Python 防止死锁的方法
2020/07/29 Python
HTML5对手机页面长按会粘贴复制禁用的解决方法
2016/07/19 HTML / CSS
Orvis官网:自1856年以来,优质服装、飞钓装备等
2018/12/17 全球购物
巴西香水和化妆品购物网站:The Beauty Box
2019/09/03 全球购物
工作推荐信范文
2014/05/10 职场文书
学习朴航瑛老师爱岗敬业先进事迹思想汇报
2014/09/17 职场文书
群众路线自我剖析材料
2014/10/08 职场文书
2014年基层党支部工作总结
2014/12/04 职场文书
2015年银行大堂经理工作总结
2015/04/24 职场文书
2015年班干部工作总结
2015/04/29 职场文书
学习雷锋主题班会
2015/08/14 职场文书
原生Js 实现的简单无缝滚动轮播图的示例代码
2021/05/10 Javascript