A geospatial database is specifically designed (or extended) to store and query data related to the Earth’s surface. Rather than just focusing on numeric or textual data, these systems handle coordinates, polygons, linestrings, and other spatial objects that define locations and shapes. Queries typically revolve around spatial relationships, like finding points within a boundary, measuring distances, or detecting intersections between shapes.
Historically, geospatial capabilities were mostly the domain of specialised systems such as PostGIS (an extension of PostgreSQL) or dedicated GIS software. SurrealDB offers geospatial features to unify location-related data with other data models (relational, document, graph, vector, and so on) under one roof with no extensions required.
In this section, you’ll learn how to think like a geospatial database user: represent location with geometry or geography types, index and query with spatial predicates, and combine SurrealDB’s geo functions with the rest of your data.
Core concepts of geospatial data
Coordinate reference systems (CRS): Coordinates can be stored in different projections. A common choice is WGS84 for latitude and longitude (EPSG:4326), used by GPS. Other systems exist for local or projected coordinates.
Geometry types: Including points, linestrings, polygons, and multi-variants—see Geometry types.
Spatial relationships: Operations such as contains, intersects, within, touches, or disjoint—see Spatial queries.
Distance and proximity: Measuring distance between geometries, buffers, and geohash-style encodings—see Distance and proximity.
For reference types and function signatures, see Geometries and Geo functions.