How to use the mgrs.MGRS function in mgrs

To help you get started, we’ve selected a few mgrs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github icesat-2UT / PhoREAL / icesatUtils.py View on Github external
epsg_code = '326' + utm_band
        elif lat >= 84:
            # epsg_code = '3411'
            epsg_code = EPSG_ARCTIC
        elif lat <= -80:
            # epsg_code = '3412'
            epsg_code = EPSG_ANTARCTIC
        else:
            epsg_code = '327' + utm_band
        return epsg_code


    elif module == 'mgrs':
        import mgrs
        if m == None:
            m = mgrs.MGRS()

        # UTM defined in [-80, 84)
        if DEG_ANTARCTIC <= lat < DEG_ARCTIC:
            # [-80,84)
            mgrs_code = m.toMGRS(lat, lon, MGRSPrecision=5) # 1m precision
            UTM_code = m.MGRSToUTM(mgrs_code)
            utm_band = str(UTM_code[0]).zfill(2)
            hemi = UTM_code[1].decode() # 'N' or 'S'

            if not (hemi == 'N' or hemi == 'S'):
                # debug check since code is new
                print('warning ({}): hemi={} is something other than N or S'.format(module, hemi))

            epsg_code = '326' + utm_band # N
            if hemi == 'S':
                epsg_code = '327' + utm_band
github 0x90 / wifi-arsenal / wraith / subpanels.py View on Github external
def __init__(self,toplevel,chief):
        self._mgrs = mgrs.MGRS()
        gui.SimplePanel.__init__(self,toplevel,chief,"Conversions","widgets/icons/convert.png")
github 0x90 / wifi-arsenal / wraith / dyskt / rto.py View on Github external
def _setup(self,host,port):
        """ connect to Nidus for data transfer and pass sensor up event """
        try:
            # get mgrs converter
            self._mgrs = mgrs.MGRS()

            # connect to data store
            self._nidus = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
            self._nidus.connect((host,port))
        except socket.error as e:
            raise RuntimeError("RTO:Nidus:%s" % e)
        except Exception as e:
            raise RuntimeError("RTO:Unknown:%s" % e)
github staaldraad / fastfluxanalysis / Geolocate.py View on Github external
def getMGRSVal(self,lat,lon):
        m = mgrs.MGRS()
        c = m.toMGRS(lat,lon)
        ind = 1
        for i in range(1,len(c)):
            if c[i].isalpha():
                ind = i
                break
                
        v1 = int(c[:ind])*(ord(c[ind:ind+1])+ord(c[ind+1:ind+2]))
        v2 = int(c[ind+3:])

        return (v1*v2,c)
github icesat-2UT / PhoREAL / source_code / icesatUtils.py View on Github external
epsg_code = '326' + utm_band
        elif lat >= 84:
            # epsg_code = '3411'
            epsg_code = EPSG_ARCTIC
        elif lat <= -80:
            # epsg_code = '3412'
            epsg_code = EPSG_ANTARCTIC
        else:
            epsg_code = '327' + utm_band
        return epsg_code


    elif module == 'mgrs':
        import mgrs
        if m == None:
            m = mgrs.MGRS()

        # UTM defined in [-80, 84)
        if DEG_ANTARCTIC <= lat < DEG_ARCTIC:
            # [-80,84)
            mgrs_code = m.toMGRS(lat, lon, MGRSPrecision=5) # 1m precision
            UTM_code = m.MGRSToUTM(mgrs_code)
            utm_band = str(UTM_code[0]).zfill(2)
            hemi = UTM_code[1].decode() # 'N' or 'S'

            if not (hemi == 'N' or hemi == 'S'):
                # debug check since code is new
                print('warning ({}): hemi={} is something other than N or S'.format(module, hemi))

            epsg_code = '326' + utm_band # N
            if hemi == 'S':
                epsg_code = '327' + utm_band

mgrs

MGRS coordinate conversion for Python

MIT
Latest version published 4 months ago

Package Health Score

71 / 100
Full package analysis