Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products.

Python 2 is no longer supported by the community. We recommend that you migrate Python 2 apps to Python 3.

The GeoPoint Class

Stay organized with collections Save and categorize content based on your preferences.

Class GeoPoint represents a point on the earth's surface represented by latitude and longitude coordinates.

Caution: **This solution is no longer recommended:** Apps that use this API can only run in the Python 2 runtime and will need to upgrade to a [recommended solution](/appengine/docs/legacy/standard/python/migrate-to-python3/migrating-services#migration_paths_for_bundled_services) before migrating to the Python 3 runtime.

GeoPoint is defined in the module google.appengine.api.search.

Introduction

The GeoPoint class allows you to make map locations searchable. You start by instantiating the GeoPoint class and then pass that object to a specific document field:

from google.appengine.api import search
...
# Construct the GeoPoint class
geopoint = search.GeoPoint(latitude, longitude)

fields = [search.TextField(name='name', value=store_name),
          search.TextField(name='address', value=store_address),
          # Construct a GeoField passing geopoint as the value of that field
          search.GeoField(name='store_location', value=geopoint)
         ]

For more information about performing location-based searches, please see Queries on geopoint fields.

Constructor

The constructor for class GeoPoint is defined as follows:

GeoPoint(latitude, longitude)

A point on the earth's surface represented by latitude and longitude coordinates.

Arguments

latitude

The angle between the equatorial plan and a line that passes through the GeoPoint, between -90 and 90 degrees.

longitude

The angle east or west from a reference meridian to another meridian that passes through the GeoPoint, between -180 and 180 degrees.

Exceptions

TypeError

Any of the parameters has an invalid type, or an unknown attribute was passed.

ValueError

An invalid value was passed for one of the parameters.

Properties

An instance of class GeoPoint has the following properties:

latitude

An angular distance, in degrees, from the equator. Points located to the south of the equator have negative values, while points located to the north of it have positive values.

longitude

An angular distance, in degrees, from the prime meridian. Points located to the west of the prime meridian have positive values, while points located to the east of it have negative values.