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)
問(wèn)題經(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)行劃分。
Codeimport randomfrom mpl_toolkits import mplot3dimport numpy as npimport mathimport matplotlib.pyplot as plt%matplotlib inlineax=plt.axes(projection='3d')N=1000x=[]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 thetafor 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)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. 完美解決vue 中多個(gè)echarts圖表自適應(yīng)的問(wèn)題2. SpringBoot+TestNG單元測(cè)試的實(shí)現(xiàn)3. idea配置jdk的操作方法4. Springboot 全局日期格式化處理的實(shí)現(xiàn)5. IntelliJ IDEA設(shè)置默認(rèn)瀏覽器的方法6. Docker容器如何更新打包并上傳到阿里云7. Java GZip 基于內(nèi)存實(shí)現(xiàn)壓縮和解壓的方法8. python 浮點(diǎn)數(shù)四舍五入需要注意的地方9. JAMon(Java Application Monitor)備忘記10. vue實(shí)現(xiàn)web在線聊天功能
