How to use the h3.h3.GeoCoord function in h3

To help you get started, we’ve selected a few h3 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 uber / h3-py / h3 / h3.py View on Github external
def _coord_array_to_geo_coord(coord_array, geo_json_conformant=False):
    if geo_json_conformant:
        lng = coord_array[0]
        lat = coord_array[1]
    else:
        lat = coord_array[0]
        lng = coord_array[1]

    return GeoCoord(
        degs_to_rads(mercator_lat(lat)), degs_to_rads(mercator_lng(lng)))
github uber / h3-py / h3 / h3.py View on Github external
def geo_to_h3(lat, lng, res):
    """Index a geo-coordinate at a resolution into an h3 address"""
    geo_coord = GeoCoord(
        degs_to_rads(mercator_lat(lat)), degs_to_rads(mercator_lng(lng)))
    return h3_to_string(libh3.geoToH3(byref(geo_coord), res))
github uber / h3-py / h3 / h3.py View on Github external
def _polygon_array_to_geofence(polygon_array, geo_json_conformant=False):
    num_verts = len(polygon_array)
    GeoCoordArray = GeoCoord * num_verts
    geo_coord_array = GeoCoordArray()
    for i in range(num_verts):
        geo_coord_array[i] = _coord_array_to_geo_coord(polygon_array[i],
                                                       geo_json_conformant)

    return Geofence(num_verts, cast(geo_coord_array, c_void_p))
github uber / h3-py / h3 / h3.py View on Github external
def h3_to_geo(h3_address):
    """Reverse lookup an h3 address into a geo-coordinate"""
    geo_coord = GeoCoord()
    libh3.h3ToGeo(string_to_h3(h3_address), byref(geo_coord))
    return [
        mercator_lat(rads_to_degs(geo_coord.lat)),
        mercator_lng(rads_to_degs(geo_coord.lng))
    ]