A spatial reference system (SRS) is a coordinate-based geographic system. OceanBase Database currently supports only the default SRS.
Types of spatial reference systems
Spatial reference systems (SRS) are mainly divided into the following categories:
- Geographic SRS: Based on the Earth's ellipsoid, it uses latitude and longitude as coordinates, typically expressed in degrees. It is suitable for describing real-world geographic locations, such as GPS coordinates. Common examples include WGS 84 (SRID=4326).
- Projected SRS: Projects geographic coordinates from an ellipsoid onto a plane, using a Cartesian coordinate system with length units (such as meters or feet). It is commonly used in planar map displays and spatial analysis.
In addition, OceanBase Database supports a special SRS called SRID 0, which represents an infinite, unitless 2D 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 gaming, simulation, and engineering design. It is important to note that SRID 0 is the default SRID for spatial data, and its usage should be carefully distinguished from real 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 above example shows the SRS commonly used in GPS systems. The SRS_NAME is WGS 84, and the SRS_ID is 4326. The DEFINITION field is in the Well-Known Text (WKT) format, which describes the detailed structure of the SRS. WKT is a standard text representation method defined based on Extended Backus-Naur Form (EBNF). It is suitable for storing geometric data and can also be used as an SRS description in GIS scenarios.
Please note the following two points:
- The
SRS_IDvalue can be directly used as the SRID value for spatial data or as a parameter in spatial functions. - When performing spatial operations, all participating geometric objects 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 AutoNavi, 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." All calculations are performed as pure mathematical plane operations, and the results have no geographic meaning.
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, such as:
- Coordinates in game maps and virtual scenes
- Local coordinate systems such as CAD engineering drawings and architectural floor plans
- Abstract charts, flowcharts, and simulated data for testing
Additionally, in geographic information queries, since SRID=0 is considered an unbounded plane 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 lower 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.
