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?


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.

  • 1
    there's this implementation in python here following @MrTJ comment but it's bit more complicated then he explained it. – Rhibi Hamza Apr 16 '20 at 8:01
  • Please don't post links only. They become obsolete when the site goes down. Please include a short explanation or excerpt from the referenced site. – John K. N. Apr 16 '20 at 8:23
  • 1
    You're totally right but this was a github project link to install the module dynamodb geo for python. The explaination of how it works is same as @MrTJ comment but with complication on how to get the closest points, it will require going deeply into the implementation details. – Rhibi Hamza Apr 16 '20 at 10:05

Well, this is about a year late and I doubt you still need this solution, but the only way you can really do that is use Jython, or you'd have to set up some Java "server" locally and communicate with that from your python server (probably, the greater of the two evils, but I guess it depends where you're standing!).

(Neither solution is probably very practical for you..)

  • au contraire, The question is very much valid, and your solutions are very nice workarounds. The only reason I don't accept the answer is that I'm looking for a full Pythonic access to Dynamo. – Adam Matan May 23 '15 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.