Google Geo Type API Client Library

0.6.0 · active · verified Thu Apr 16

The `google-geo-type` library provides Python protobuf definitions for common geographic types used across Google APIs, such as LatLng, Viewport, and PostalAddress. It is part of the larger `google-cloud-python` monorepo. Currently at version 0.6.0, it follows the release cadence of the Google Cloud client libraries, with updates typically bundled with other related packages.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and create instances of common geographic types like `LatLng` and `Viewport` using their respective protobuf definition modules.

from google.geo.type import latlng_pb2
from google.geo.type import viewport_pb2

# Create a LatLng object
latitude = 34.052235
longitude = -118.243683
point = latlng_pb2.LatLng(latitude=latitude, longitude=longitude)
print(f"Point: ({point.latitude}, {point.longitude})")

# Create a Viewport object
viewport = viewport_pb2.Viewport(
    low=latlng_pb2.LatLng(latitude=33.9, longitude=-118.3),
    high=latlng_pb2.LatLng(latitude=34.1, longitude=-118.1)
)
print(f"Viewport Low: ({viewport.low.latitude}, {viewport.low.longitude})")
print(f"Viewport High: ({viewport.high.latitude}, {viewport.high.longitude})")

view raw JSON →