Using AWS DynamoDB Geospatial index with Python

awsdynamodbpythonspatial

Amazon's AWS DynamoDB features Geospatial Indexing, which facilitates geo queries:

Query Support: Box queries return items that fall within a pair of geo
points that define a rectangle as projected on a sphere. Radius
queries return items that fall within a given distance from a geo
point.

The problem is that the boto, the Python library for accessing AWS Service, lacks any reference to geo object. The Java equivalent, on the other hand, has such support.

Is there a way to use the geo features of DynamoDB on AWS using Python?

Best Answer

The "geospatial feature" of dynamodb isn't really anything else then calculating a geohash from the coordinates, storing the hash in the same row, create an index on the hash, and when querying based on a location, calculate the hash of that location and compare to the indexed hashes in the table. The algorithm of geohash is really simple and with a reasonable knowledge it could be coded in a couple of hours in any language. You could even create a lambda function (since October 2015 even in Python!) that is attached to a dynamodb stream and stores the geohash automagically.

But probably it is a much better idea to check out dynamodb streams + lambda + cloudsearch integration that has native support for geospatial queries and boto also has a cloudsearch interface.