python:地图图幅号转经纬度范围

输入地图图幅编号,例如:j47e008022,输出该图幅对应的经纬度范围:

101.25

38.66666666666664

101.25

38.83333333333336

适用于:1:50万,1:25万,1:10万,1:5万,1:2.5万,1:1万,1:5000比例尺图幅

def getRow(strMapCode):
    row = strMapCode[4:7]
    return row


def getcol(strMapCode):
    col = strMapCode[7:10]
    return col


def getLondiff(strMapCode):
    str = strMapCode[3]
    dlondif=0.0
    if str=='B':
        dlondif = 3*60*60
    elif str=='b':
        dlondif = 3 * 60 * 60
    elif str == 'C':
        dlondif = 1*60*60 + 30*60
    elif str == 'c':
        dlondif = 1*60*60 + 30*60
    elif str == 'D':
        dlondif = 30*60
    elif str=='d':
        dlondif = 30*60
    elif str == 'E':
        dlondif = 15*60
    elif str == 'e':
        dlondif = 15*60
    elif str == 'F':
        dlondif = 7*60 +30
    elif str == 'f':
        dlondif = 7*60 +30
    elif str == 'G':
        dlondif = 3*60 + 45
    elif str == 'g':
        dlondif = 3*60 + 45
    elif str == 'H':
        dlondif = 1*60 + 52.5
    elif str == 'h':
        dlondif = 1*60 + 52.5
    return dlondif


def getLatdiff(strMapCode):
    str = strMapCode[3]
    dlatdif=0.0
    if str=='B':
        dlatdif = 2*60*60
    elif str=='b':
        dlatdif = 2*60*60
    elif str == 'C':
        dlatdif = 1*60*60
    elif str == 'c':
        dlatdif = 1*60*60
    elif str == 'D':
        dlatdif = 20*60
    elif str=='d':
        dlatdif = 20*60
    elif str == 'E':
        dlatdif = 10*60
    elif str == 'e':
        dlatdif = 10*60
    elif str == 'F':
        dlatdif = 5*60
    elif str == 'f':
        dlatdif = 5*60
    elif str == 'G':
        dlatdif = 2*60 + 30
    elif str == 'g':
        dlatdif = 2*60 + 30
    elif str == 'H':
        dlatdif = 1*60 + 15
    elif str == 'h':
        dlatdif = 1*60 + 15
    return dlatdif

def getMapCodeMinLlonlat(strMapCode):
    strFirst = strMapCode[0]
    a = ord(strFirst)
    if a>=65 and a<=86:
        a=a-64
    elif a>=97 and a<=118:
        a=a-96
    strSecod = strMapCode[1:3]
    b=int(strSecod)
    dlong = getLondiff(strMapCode)
    dlat = getLatdiff(strMapCode)

    col = int(getcol(strMapCode))
    row = int(getRow(strMapCode))

    wsLong = (b - 31) * 6 * 60 * 60 + (col - 1) * dlong;
    wsLat = (a - 1) * 4 * 60 * 60 + (4 * 60 * 60 / dlat - row) * dlat;

    enLong = wsLong +dlong;
    enLat = wsLat+dlat;

    wsLong = wsLong/3600
    wsLat = wsLat/3600

    enLong = enLong / 3600
    enLat = enLat / 3600
    print(wsLong)
    print(wsLat)
    print(enLong)
    print(enLat)

    return wsLong, wsLat,enLong,enLat


getMapCodeMinLlonlat("F50H071003")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Guyuecc0906

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值