Оценок пока нет Converting x,y coordinates to latitude, longitude for google map with pyproj4 lib

First of all, we need to find out the data of our region by link

Example geo meta data for Israel

hddd.ddddd° (Lat/Lon Degrees)
hddd° mm.mmm' (Lat/Lon Degrees & Minutes)
hddd° mm' ss.s" (Lat/Lon Deg. Min. Sec.)
Universal Transverse Mercator (UTM)
Military Grid Reference System (MGRS)
Israel TM Grid - EPSG 2039
World Geodetic System 1984 (WGS 84) - EPSG 4326
World Geodetic System 1972 (WGS 72) - EPSG 4322
European 1950, Iraq and Israel
Israel 1993 - EPSG 4141

Next, we need to install the library pyproj4

$ pip install pyproj

Now we write code for python for converting data

import pyproj

def get_lat_lng(x, y):
    '''
    ISRAEL GEO METADATA get from https://www.expertgps.com/convert-coordinates/
    hddd.ddddd° (Lat/Lon Degrees)
    hddd° mm.mmm' (Lat/Lon Degrees & Minutes)
    hddd° mm' ss.s" (Lat/Lon Deg. Min. Sec.)
    Universal Transverse Mercator (UTM)
    Military Grid Reference System (MGRS)
    Israel TM Grid - EPSG 2039
    World Geodetic System 1984 (WGS 84) - EPSG 4326
    World Geodetic System 1972 (WGS 72) - EPSG 4322
    European 1950, Iraq and Israel
    Israel 1993 - EPSG 4141
    CODE = 972
    UTM Zone = 36R
    lat = 31.6245213
    long = 34.7210813
    '''
    wgs84 = pyproj.Proj(projparams = 'epsg:4326')
    InputGrid = pyproj.Proj(projparams = 'epsg:2039')

    c = pyproj.transform(InputGrid, wgs84, x, y)
    return {'lat': c[0], 'lng': c[1]}

coord = get_lat_lng(174055.2462, 614374.1559)
print(coord) #{'lat':31.6208351818742, 'lng': 34.72593812619558}

Good day :)!

Пожалуйста, оцените материал

WebSofter

Web - технологии