python實(shí)現(xiàn)經(jīng)緯度采樣的示例代碼
原理
經(jīng)度 phi,緯度 theta 處的坐標(biāo)為:
x =R* cos(phi) * cos(theta)
y = Rsin(phi) * cos(theta)
z = Rsin(theta)
問題
經(jīng)緯度采樣的采樣點(diǎn)是相同經(jīng)緯度間隔的交點(diǎn)。但是采樣1000個(gè)點(diǎn),如何劃分多少條經(jīng)線,多少條緯線相交,才能使1000個(gè)采樣點(diǎn)最均勻的分布在球面上(雖然經(jīng)緯度采樣本來(lái)就不均勻,但對(duì)于不同的采樣點(diǎn)個(gè)數(shù)應(yīng)該有一種相對(duì)最均勻的經(jīng)緯線劃分)?求大佬指教!
我目前是將緯度每10度進(jìn)行劃分。
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
#經(jīng)度
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\\經(jīng)緯度采樣.png")
效果

到此這篇關(guān)于python實(shí)現(xiàn)經(jīng)緯度采樣的示例代碼的文章就介紹到這了,更多相關(guān)python 經(jīng)緯度采樣內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Python利用Redis計(jì)算經(jīng)緯度距離案例
- Python?pyecharts實(shí)時(shí)畫圖自定義可視化經(jīng)緯度熱力圖
- 利用Python提取圖片經(jīng)緯度并鎖定拍照地點(diǎn)
- Python編程調(diào)用百度API實(shí)現(xiàn)地理位置經(jīng)緯度坐標(biāo)轉(zhuǎn)換示例
- python 經(jīng)緯度求兩點(diǎn)距離、三點(diǎn)面積操作
- Python調(diào)用高德API實(shí)現(xiàn)批量地址轉(zhuǎn)經(jīng)緯度并寫入表格的功能
- Python如何批量處理經(jīng)緯度數(shù)據(jù)并生成位置信息
相關(guān)文章
python密碼學(xué)對(duì)稱和非對(duì)稱密碼教程
這篇文章主要為大家介紹了python密碼學(xué)對(duì)稱和非對(duì)稱密碼教程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05
python 實(shí)現(xiàn)簡(jiǎn)單的吃豆人游戲
這篇文章主要介紹了python 如何實(shí)現(xiàn)簡(jiǎn)單的吃豆人游戲,幫助大家更好的理解和學(xué)習(xí)使用python制作游戲,感興趣的朋友可以了解下2021-04-04
如何用Python 實(shí)現(xiàn)全連接神經(jīng)網(wǎng)絡(luò)(Multi-layer Perceptron)
這篇文章主要介紹了如何用Python 實(shí)現(xiàn)全連接神經(jīng)網(wǎng)絡(luò)(Multi-layer Perceptron),幫助大家更好的進(jìn)行機(jī)器學(xué)習(xí),感興趣的朋友可以了解下2020-10-10

