Does Amazon Web Services have a solution to store objects in a database with a latitude and longitude and then to do a geo query on them to give you all objects in a specific radius and sort them by what is closest to the center of that radius?
There are geohashing solutions for DynamoDB but those don’t allow you to sort results by what is closest to the target location.
3
Answers
I think the term you’re looking for is spatial search or spatial indexing. DynamoDB does not have such a feature, but the SQL-based products in the RDS area support spatial indices, including geofencing just like their “normal” counterparts (MySQL, Postrgres etc.).
If you are looking for a low-touch solution, you can look into the different Aurora options, including Aurora Serverless. For example, Aurora MySQL has support for different spatial types/indices.
There are many offerings from AWS which can offer geo-spatial queries, depending on your specific use-case will determine which option is best for you.
NoSQL
Relational
Use RDS PostgreSQL with PostGIS, its spatial extension. PostGIS gives you geospatial data types, function, and indexes. With that you can ask all sorts of geospatial questions in a performant way using plain old SQL 🙂
You can use ST_DWithin to get what you want, for example:
This query will find the nearest hospital to each school that is within 3000 units of the school.
ST_DWithin
leverages spatial indexes to perform the search faster so make sure you index your geom. If the units of the spatial reference is meters then units would be meters.Take a look at this intro to PostGIS workshop to get an overview of PostGIS and its capabilities. Visit Managing spatial data with the PostGIS extension to see how to work with PostGIS on AWS.
Hope this helps.