table.get_nearest(point, index='indexname'[, max_results=100, max_dist=100000, unit='m', geo_system='WGS84']) → array
Return a list of documents closest to a specified point based on a geospatial index, sorted in order of increasing distance.
The index
argument is mandatory. Optional arguments are:
max_results
: the maximum number of results to return (default 100).unit
: Unit for the distance. Possible values are m
(meter, the default), km
(kilometer), mi
(international mile), nm
(nautical mile), ft
(international foot).max_dist
: the maximum distance from an object to the specified point (default 100 km).geo_system
: the reference ellipsoid to use for geographic coordinates. Possible values are WGS84
(the default), a common standard for Earth’s geometry, or unit_sphere
, a perfect sphere of 1 meter radius.The return value will be an array of two-item objects with the keys dist
and doc
, set to the distance between the specified point and the document (in the units specified with unit
, defaulting to meters) and the document itself, respectively. The array will be sorted by the values of dist
.
Example: Return a list of the closest 25 enemy hideouts to the secret base.
secret_base = r.point(-122.422876, 37.777128) r.table('hideouts').get_nearest(secret_base, index='location', max_results=25).run(conn)
If you wish to find all points within a certain radius of another point, it’s often faster to use get_intersecting with circle, as long as the approximation of a circle that
circle
generates is sufficient.
Couldn't find what you were looking for?
© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/python/get_nearest/