The spatial reference system (SRS) of spatial data is a coordinate-based geographic location system. OceanBase Database supports only the system default SRS.
Spatial reference system types
Spatial reference systems (SRSs) are mainly classified into the following types:
- Geographic SRSs: Based on the Earth's ellipsoid, they use longitude and latitude as coordinates, typically represented in angular units (such as degrees). They are suitable for describing real-world geographic locations (such as GPS coordinates). For example, the commonly used WGS 84 (SRID=4326) is a geographic SRS.
- Projected SRSs: These project geographic coordinates on an ellipsoid onto a flat plane, using a Cartesian coordinate system with length units (such as meters and feet). They are commonly used in flat map displays and spatial analysis.
In addition, OceanBase supports a special spatial reference system —— SRID 0, which represents an infinite, unitless two-dimensional plane (an abstract Cartesian coordinate system). This coordinate system has no geographic meaning and does not correspond to any location on the Earth's surface. It is typically used in virtual or local coordinate scenarios such as games, simulations, and engineering designs. It is important to note that SRID 0 is the default SRID for spatial data. When using it, it is crucial to distinguish its purpose from that of real-world geographic coordinate systems.
Obtain 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 in 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 preceding example describes an SRS used in a GPS. Its name (SRS_NAME) is WGS 84 and its ID (SRS_ID) is 4326.
The SRS definition in the DEFINITION column is a well-known text (WKT) value. WKT is defined in the extended Backus–Naur form (EBNF). WKT can be used either as a data format (WKT-Data) or as an SRS definition in a GIS.
The SRS_ID value represents a geometry value of the same type as SRID or is passed as an SRID parameter to a spatial function. SRID 0 (the Cartesian plane without units) is a special, valid SRS ID that can be used for any spatial data calculation that depends on SRID values. For the calculation of multiple geometry values, all values must have the same SRID; otherwise, an error occurs.
SRID selection guidelines
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, for example:
- GPS coordinates (longitude and latitude)
- 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)
We recommend that you use SRID=0 with caution. SRID=0 indicates "no coordinate system." All calculations are performed as if on a pure mathematical plane, and the results have no geographic meaning.
Warning
Do not set real-world longitude and latitude data to SRID=0. Otherwise, the analysis results for distance and area will be severely incorrect.
SRID=0 is suitable only for scenarios where the data does not represent real-world locations on the Earth, such as the following:
- Coordinates in game maps and virtual scenes
- Local coordinate systems in CAD engineering drawings and architectural plans
- Abstract charts, flowcharts, or simulated test data
In addition, in geographic information queries, since SRID=0 is considered an unbounded plane Cartesian coordinate system, the database cannot, like for SRID=4326 (WGS 84), use predefined fine-grained grid divisions based on longitude and latitude ranges. 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 data configured with the correct spatial reference system.