栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python 随机生成 范围内(周围) 经纬度 坐标信息

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python 随机生成 范围内(周围) 经纬度 坐标信息

import random
import math
#  参数含义
# base_log:经度基准点,
# base_lat:维度基准点,
# radius:距离基准点的半径
def generate_random_gps(base_log=None, base_lat=None, radius=None):
    radius_in_degrees = radius / 111300
    u = float(random.uniform(0.0, 1.0))
    v = float(random.uniform(0.0, 1.0))
    w = radius_in_degrees * math.sqrt(u)
    t = 2 * math.pi * v
    x = w * math.cos(t)
    y = w * math.sin(t)
    longitude = y + base_log
    latitude = x + base_lat
    # 这里是想保留14位小数
    loga = '%.6f' % longitude
    lata = '%.6f' % latitude
    return loga, lata
longitude1 = []
longitude2 = []
for i in range(96):
    longitude_, latitude_ = generate_random_gps(base_log=114.1747112313, base_lat=33.02654402131123123, radius=100)
    longitude1.append(longitude_)
    longitude2.append(latitude_)

for i in range(96):
    print(longitude1[i])


for i in range(96):
    print(longitude2[i])
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/269182.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号