A spatial reference system (SRS) is a coordinate-based system for representing geographic locations. OceanBase Database only supports the default SRS in its current version.
Types of spatial reference systems
Spatial reference systems (SRS) are mainly categorized into the following types:
- Geographic SRS: Based on the Earth's ellipsoid, it uses latitude and longitude as coordinates, typically represented in degrees. It is suitable for describing real-world geographic locations, such as GPS coordinates. Common examples include WGS 84 (SRID=4326).
- Projected SRS: Geographic coordinates on an ellipsoid are projected onto a plane using a Cartesian coordinate system, with units such as meters or feet. These are commonly used in planar map displays and spatial analysis.
Additionally, OceanBase Database supports a special SRS called SRID 0, which represents an infinite, unitless 2D plane (an abstract Cartesian coordinate system). This coordinate system lacks geographic meaning and does not correspond to any location on Earth. It is typically used in virtual or local coordinate scenarios such as gaming, simulation, and engineering design. Notably, SRID 0 is the default SRS for spatial data, and its use should be carefully distinguished from real geographic coordinate systems.
Query spatial reference system information
You can query the INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS system table to obtain information about the built-in spatial reference systems of the database. For example, the definition of SRID 4326 (WGS 84) is as follows:
obclient> SELECT * FROM INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS
WHERE SRS_ID = 4326\G
*************************** 1. row ***************************
SRS_NAME: WGS 84
SRS_ID: 4326
ORGANIZATION: EPSG
ORGANIZATION_COORDSYS_ID: 4326
DEFINITION: GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]]
DESCRIPTION: NULL
1 row in set
The above example demonstrates an SRS widely used in GPS systems. The SRS_NAME is WGS 84, and the SRS_ID is 4326. The DEFINITION field is in WKT (Well-Known Text) format, describing the detailed structure of the SRS. WKT is a standard text representation method defined based on EBNF (Extended Backus-Naur Form). It is suitable for storing geometric data and can also be used to describe SRS in GIS scenarios.
Note the following two points:
- The
SRS_IDvalue can be directly used in the SRID field of spatial data or in relevant parameters of spatial functions. - When performing spatial operations, all geometric objects involved must have the same SRID. Otherwise, an error will occur.
SRID selection guide
When using spatial data, correctly setting the SRID (Spatial Reference System Identifier) is crucial for ensuring the accuracy of the calculation results. Please select based on your data type.
We recommend using SRID=4326. Most geographic applications should use SRID=4326. SRID=4326 supports precise distance, area, and buffer calculations and conforms to international standards, making it easy to integrate with other GIS systems. It is suitable for the following scenarios, such as:
- GPS coordinates (latitude and longitude)
- Coordinates returned by mobile location services and map APIs (such as Amap, Google Maps, and Baidu Maps)
- Geographic information such as cities, roads, and points of interest (POIs)
Use SRID=0 with caution. SRID=0 indicates "no coordinate system" and treats all calculations as pure mathematical plane operations, resulting in results without geographic significance.
Warning
Do not set real latitude and longitude data to SRID=0. Otherwise, the analysis results, such as distance and area, will be severely incorrect.
SRID=0 is only suitable for scenarios where the data does not represent real-world locations on Earth, such as:
- Coordinates in game maps and virtual scenes
- Local coordinate systems in CAD engineering drawings and architectural plans
- Abstract charts, flowcharts, and simulated test data
Additionally, in geographic information queries, since SRID=0 is considered an unbounded Cartesian coordinate system, the database cannot perform predefined fine-grained mesh partitioning based on latitude and longitude ranges as it does for SRID=4326 (WGS 84). This lack of spatial index resolution results in reduced index filtering efficiency for SRID=0 (generating excessive false positives). In high-concurrency or large-scale data scenarios, the query performance of SRID=0 is significantly lower than that of SRID=4326 configured with the correct spatial reference system.