python 经纬度转为标准的1:10000图幅号

coding=utf-8

import re, traceback
from PyQt5.QtWidgets import QMessageBox
import sys, traceback
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QAction
from PyQt5 import QtCore, QtGui, QtWidgets
import os, sys
def tufu2jwd(tufustr):
jingweidu = []
h = tufustr[:1]
l = float(tufustr[1:3])
mappableCode = tufustr[3:4]
h1 = float(tufustr[4:7])
l1 = float(tufustr[7:10])
bilichi = bilichi_dict[mappableCode]
xy = bilichi_begin[str(bilichi)]
x2 = float(xy.split(“,”)[0])
y2 = float(xy.split(“,”)[1])
hDouble = float(bilichi_line[h])

ymax = (hDouble*14400-(h1-1)*y2)/3600
xmin = ((l-31)*21600+(l1-1)*x2)/3600
ymin = ymax-y2/3600
xmax=xmin+x2/3600
jingweidu.append(xmin)
jingweidu.append(ymin)
jingweidu.append(xmax)
jingweidu.append(ymax)
return jingweidu,bilichi

def jwd2tufu(x,y,scale, bilichi_begin, bilichi_line, bilichi_dict):
zeroLength=“000”
xy = bilichi_begin[str(scale)]
x2 = float(xy.split(“,”)[0])
y2 = float(xy.split(“,”)[1])
h = str(int(float(y/4))+1)
l = str(int(float(x/6))+31)
h1 = str(int(float(14400/y2)-float((y%4)3600/y2)))
l1 = str(int(float(x%6
3600/x2))+1)
hkey = getkey(bilichi_line, h)
scaleCode = getkey(bilichi_dict,scale)
hk1 = zeroLength[0:len(zeroLength)-len(h1)]+h1
lk1 = zeroLength[0:len(zeroLength)-len(l1)]+l1
return hkey + l + scaleCode + hk1 + lk1

def getkey(bilechi_line, scale):
scale_str = “A”
for key,value in bilechi_line.items():
if value == scale:
scale_str = key
break
return scale_str

def degree2sjz(text):
return re.sub(“(-?\d{1,3})°(\d{1,3})′(\d{1,3})″”, lambda x:str(float(x.group(1)) + float(x.group(2))/60 + float(x.group(3))/3660), text)

def sjz2degree(d_data):
d = int(d_data)
m = int((d_data-d)*60)
s = int(((d_data-d)*60-m)*60)
return str(d) + “°” + str(m) + “′” + str(s) + “″”

import math, pi

#大地2000转经纬度
def GetLatLon2(B, C, IsSix):
# 带号
D = math.trunc(C / 1000000)
# 中央经线(单位:弧度)
K = 0
if IsSix:
K = D * 6 - 3 # 6度带计算
else:
pass
K = D * 3 # 3度带计算
L = B / (6378245 * (1 - 0.006693421623) * 1.0050517739)
M = L + (0.00506237764 * math.sin(2 * L) / 2 - 0.00001062451 * math.sin(4 * L) / 4 + 0.0000002081 * math.sin(
6 * L) / 6) / 1.0050517739
N = L + (0.00506237764 * math.sin(2 * M) / 2 - 0.00001062451 * math.sin(4 * M) / 4 + 0.0000002081 * math.sin(
6 * M) / 6) / 1.0050517739
O = L + (0.00506237764 * math.sin(2 * N) / 2 - 0.00001062451 * math.sin(4 * N) / 4 + 0.0000002081 * math.sin(
6 * N) / 6) / 1.0050517739
P = L + (0.00506237764 * math.sin(2 * O) / 2 - 0.00001062451 * math.sin(4 * O) / 4 + 0.0000002081 * math.sin(
6 * O) / 6) / 1.0050517739
Q = L + (0.00506237764 * math.sin(2 * P) / 2 - 0.00001062451 * math.sin(4 * P) / 4 + 0.0000002081 * math.sin(
6 * P) / 6) / 1.0050517739
R = L + (0.00506237764 * math.sin(2 * Q) / 2 - 0.00001062451 * math.sin(4 * Q) / 4 + 0.0000002081 * math.sin(
6 * Q) / 6) / 1.0050517739
S = math.tan®
T = 0.006738525415 * (math.cos®) ** 2
U = 6378245 / math.sqrt(1 - 0.006693421623 * (math.sin®) ** 2)
V = 6378245 * (1 - 0.006693421623) / (math.sqrt((1 - 0.006693421623 * (math.sin®) ** 2))) ** 3
W = 5 + 3 * S ** 2 + T - 9 * T * S ** 2
X = 61 + 90 * S ** 2 + 45 * S ** 4
Y = 1 + 2 * S ** 2 + T ** 2
Z = 5 + 28 * S ** 2 + 24 * S ** 4 + 6 * T + 8 * T * S ** 2
print(math.pi)
Lat = (180 / math.pi) * (
R - (C - D * 1000000 - 500000) ** 2 * S / (2 * V * U) + (C - D * 1000000 - 500000) ** 4 * W / (
24 * U ** 3 * V) - (C - D * 1000000 - 500000) ** 6 * X / (7200 * U ** 5 * V))
Lon = (180 / math.pi) * (C - D * 1000000 - 500000) * (
1 - (C - D * 1000000 - 500000) ** 2 * Y / (6 * U ** 2) + (C - D * 1000000 - 500000) ** 4 * Z / (
120 * U ** 4)) / (U * math.cos§)
Lat = Lat
Lon = K + Lon
return (Lon, Lat)

def dd2000_tfh(x, y):
bilichi_dict = {“A”:1000000, “B”:500000, “C”:250000, “D”:100000, “E”:50000, “F”:25000, “G”:10000, “H”:5000}
bilichi_begin = {“1000000”:“21600,14400”, “500000”:“10800,7200”, “250000”:“5400,3600”, “100000”:“1800,1200”,
“50000”:“900,600”, “25000”:“450,300”, “10000”:“225,150”, “5000”:“112.5,75”}
bilichi_line = {“A”:“1”,“B”:“2”,“C”:“3”,“D”:“4”,“E”:“5”,“F”:“6”,“G”:“7”,“H”:“8”,“I”:“9”,“J”:“10”,“K”:“11”,“L”:“12”,“M”:“13”,“N”:“14”}
#jingweidu,bilichi=tufu2jwd(“F50G007011”)
#print(jingweidu, bilichi)
#print(jwd2tufu(jingweidu[0], jingweidu[1], bilichi))
#[114.625, 23.708333333333332, 114.6875, 23.75]
jingweidu = GetLatLon2(x, y, ‘3度带’)
print(jingweidu)
return jwd2tufu(jingweidu[0], jingweidu[1], 10000, bilichi_begin, bilichi_line, bilichi_dict)

def main(self):
def ye():
try:
x = float(self.lineEdit.text())
y = float(self.lineEdit_2.text())
tfh = dd2000_tfh(x, y)
self.lineEdit_3.setText(tfh)
except:
QMessageBox.information(None, ‘提示’, traceback.format_exc())

self.pushButton.clicked.connect(ye)

if name == ‘main’:
import jm
app = QApplication(sys.argv)
MainWindow = QMainWindow() # QMainWindow模块名
self = jm.Ui_MainWindow()
self.setupUi(MainWindow)
main(self)

MainWindow.show()
sys.exit(app.exec_())

python 经纬度转为标准的1:10000图幅号相关推荐

  1. 标准分幅下的图幅号转换成经纬度坐标【原理+源代码】

    最近要批量的把标准分幅下的图幅号转换成经纬度坐标,所以这两天写了个程序来搞定这件事情. 先举个例子说明一下这个程序的作用. 例如:计算出图幅号I50G021040的经纬度范围,即最大经度.最小经度.最 ...

  2. 百度经纬度转为谷歌经纬度

    目前有四种经纬度分类 百度经纬度 BD-09 标准经纬度 GPS 谷歌经纬度 GCJ-02(谷歌.高德.腾讯) 搜狗经纬度 (1)其他经纬度转为百度,见百度API:http://developer.b ...

  3. Python培训分享:Python内置标准异常及其解析

    本期小编为大家带来的Python培训教程是关于"Python内置标准异常及其解析"的内容,我们都知道,在Python技术运作下,总会出现一些Python无法正常处理的程序时就会发生 ...

  4. python编程输入标准-揭秘python编程技巧

    揭秘python编程技巧 一.python的标准输入和输出[root@133 wc]# vim stdin.py #!/usr/bin/python #encoding:utf-8 import sy ...

  5. 【Python面试】 列举Python中的标准异常类?

    往期面试题: 说说Python变量.函数.类的命名规则? 说说Python可变与不可变数据类型? 说说Python面向对象三大特性? 说说Python中有几种数据类型? 说说Python模块主要分哪三 ...

  6. python中exception类的_面试题 | 列举几个Python中的标准异常类?

    [摘要]今天给大家解答一道Python常见的面试题,希望这个面试栏目,给那些准备面试的同学,提供一点点帮助!小编会从最基础的面试题开始,每天一题.如果参考答案不够好,或者有错误的话,麻烦大家可以在留言 ...

  7. python生成json_如何将Python数组转为Json格式数据并存储?

    在Python中将数组转为Json数据存储时需要用到将json模块中的json.dumps()或者json.dump()方法. ·json.dumps()方法用法 使用json.dumps( )方法将 ...

  8. python实现非标准正态分布下概率密度有关计算

    总目录:Python数据分析整理 之后马上要学习朴素贝叶斯算法了,为之后的学习做好铺垫,重新用python实现了一下数据正态性的检验.根据数据的均值方差,求出小于某个值的概率,或者根据概率求出这个值是 ...

  9. python语言的标准库有哪些,python标准库函数有哪些

    PyFlux库函数是什么? PyFlux是Python编程语言的开源时间序列库.PyFlux是Python中为处理时间序列问题而创建的开源库. 该库有一系列极好的时间序列模型,包括但不限于 ARIMA ...

最新文章

  1. 找不到atlapp.h的解決方法
  2. Windows校验文件哈希hash的两种常用方式
  3. 802.11ac标准简介
  4. 程序员谈谈我的职场观(三)
  5. java 时区处理_如何使用Java处理日历时区?
  6. [Web Chart系列之三] 图形布局-Layout
  7. 如何设置CentOS 7开机自动获取IP地址详解
  8. android 串口调试助手_Arduino入门 第八节-串口通讯(基础篇)
  9. DNS分别在什么情况下使用UDP和TCP?
  10. java s类型_javasript基础——数据类型与数据类型转换
  11. 怎样获得正确的LINUX用户的文档音乐视频等目录?
  12. 部署war包到tomcat根目录
  13. python百度文库免券下载
  14. Markdown 学习小记--进阶技巧-数学公式篇
  15. 盛迈坤电子商务:自然搜索排名的优化
  16. 解除同居关系时共同财产的分割
  17. 如何合理选择 PLC
  18. android代码生成jar包并混淆
  19. 为什么父类引用可以指向子类对象 子类引用不能指向父类对象 泛型
  20. 如何使用Ajax进行与服务器交互

热门文章

  1. 常用数据结构——LinkedList
  2. HBuilder云打包ios证书申请流程
  3. 以太坊免费获取测试币
  4. 我是怎么自学 Git / GitHub 的?
  5. 小一教你轻松爬取全国40城5000+地铁站点数据!附源码和数据集
  6. 三、SIGNALING PACKET FORMATS
  7. 云原生学习的最佳路径
  8. [翻译]Energy transfer between Gd3+ and Tb3+ in phosphate glass
  9. 华南师大王璋、广东省中医院黄清春、黄闰月等揭示痛风患者肠道菌群特征
  10. Ultra96-V2 板子通信