Question: How to store location coordinates in DynamoDB?

Answered by Rafal Wilinski
Answer
Amazon DynamoDB can store location coordinates in various ways, depending on your use case and the format of the coordinates. Here are a few options for storing location coordinates in DynamoDB:
- Store coordinates as separate attributes: You can store the latitude and longitude coordinates as separate attributes in your DynamoDB table. This allows you to query and filter data based on individual coordinates. You can use the
Numberdata type to store the coordinates and use theputItem()method to insert the coordinates into the table. - Store coordinates as a string: You can store the coordinates as a string in a single attribute, such as the "latitude, longitude" format. You can use the
Stringdata type to store the coordinates and theputItem()method to insert the coordinates into the table. - Store coordinates as a point object: You can use a
pointobject, such as Point in the AWS SDK for Java andGeoJSON Pointin the AWS SDK for JavaScript, to store the coordinates in a single attribute. This allows you to perform proximity queries and spatial filters on the data. - Store coordinates as a GeoJSON point: You can use GeoJSON Point format, a standard format for representing a point on the Earth's surface, to store the coordinates in a single attribute. This allows you to perform proximity queries and spatial filters on the data and supports indexing.
It's important to note that when storing location coordinates in DynamoDB, you should consider the available indexing options. For example, you can use Global Secondary Index(GSI) with a GEOHASH key for efficient querying and filtering based on location.
Other Common DynamoDB FAQ (with Answers)
- Can colons and special characters be used in DynamoDB attributes?
- What is the access pattern in DynamoDB?
- How is data stored in DynamoDB?
- Which programming language works best with DynamoDB?
- How do you store JSON on DynamoDB?
- What are the key differences between DynamoDB and Neo4j?
- Can DynamoDB have nested objects?
- What is the maximum number of partitions in DynamoDB?
- Can we rename DynamoDB table?
- Is DynamoDB a relational database?
- Can Tableau connect to DynamoDB?
- How to forcefully delete a DynamoDB table?
- Can firehose write to DynamoDB?
- Are DynamoDB table names supposed to be unique?
- Will I be charged for DynamoDB is it is inactive?
Spend less time in the AWS console, use Dynobase.
Try 7-day free trial. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2026 Dynobase