Spatial Data Overview
Explore the fundamentals of spatial data in Cosmos DB, including GeoJSON support and spatial data types like Point, LineString, Polygon, and MultiPolygon. Understand how to configure containers for geometrical or geographical data, index spatial properties, and use system functions to perform spatial queries. This lesson equips you to model and query location-based data effectively using both SQL and the .NET SDK.
Introduction
Sometimes, we might need to store shapes, locations, or other spatial data and perform queries on them. Cosmos DB natively supports this kind of data following the GeoJSON specification.
Representations
Spatial types can be indexed in two different ways. It’s a setting on the container level, changing what the data represents and how queries perform calculations on it.
Geometrical: Data belongs to a flat (Euclidean) coordinate system.
Geographical: Data belongs to an earth coordinate system. Since the planet is not regular, data is represented on the WGS-84 coordinate reference systems (CRS). Altitude and other elements are considered during queries but are still approximated.
Longitude: ± 180 degrees from the prime meridian.
Latitude: ± 90 degrees from the equator.
Data types
There are four different types of spatial data we can use: