A Spatial Reference System (SRS) for spatial data is a coordinate-based geographic location system. The current version of OceanBase AI Database only supports the SRSs that are supported by the system by default.
Spatial reference system types
Spatial reference systems (SRSs) are mainly classified into the following categories:
- Geospatial SRS: Based on the Earth ellipsoid, using latitude and longitude as coordinates, typically expressed in degrees, suitable for describing real-world geographic locations (such as GPS coordinates). For example, the commonly used WGS 84 (SRID=4326).
- Projected SRS: Projects geographic coordinates from an ellipsoid onto a plane, using the Cartesian coordinate system and length units (such as meters or feet). This is commonly used for map display and spatial analysis.
In addition, OceanBase supports a special spatial reference system: SRID 0, which represents an infinite, dimensionless 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 gaming, simulation, and engineering design. Note that SRID 0 is the default SRID for spatial data. When using it, be cautious to distinguish its purpose from that of real geographic coordinate systems.
Query the spatial reference system information
You can query the INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS system table to obtain information about the database's built-in spatial reference systems. For example, the definition for 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 shows the SRS widely used in GPS systems, where SRS_NAME is WGS 84 and SRS_ID is 4326. The DEFINITION field is in 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 to describe SRS in GIS scenarios.
Note the following two points:
- The value of the
SRS_IDcolumn can be used directly as the SRID field for spatial data or as a related parameter in spatial functions. - When performing spatial operations, all geometric objects involved in the operation must have the same SRID; otherwise, an error will occur.
SRID selection guide
When working with spatial data, correctly setting the SRID (Spatial Reference Identifier) is crucial for ensuring the accuracy of calculation results. Please select an appropriate SRID based on your data type.
It is recommended to use SRID=4326. The vast majority of geographic applications should use SRID=4326. SRID=4326 supports precise distance, area, and buffer calculations, complies with international standards, and facilitates integration with other GIS systems. It is suitable for the following scenarios:
- GPS coordinates (latitude and longitude)
- Coordinates returned by mobile phone positioning and map APIs (such as Amap, Google Maps, and Baidu Maps)
- Geographical information such as cities, roads, and POIs
Use SRID=0 with caution. SRID=0 indicates "no coordinate system," meaning all calculations are performed as pure mathematical plane geometry, and the results have no geographic meaning.
Warning
Do not set the actual latitude and longitude data to SRID=0, otherwise the analysis results such as distance and area will be severely inaccurate.
SRID=0 is only applicable to scenarios where the data does not represent real-world geographic locations. For example:
- Coordinates in game maps and virtual scenes
- Local coordinate systems such as CAD engineering drawings and architectural floor plans
- Sample charts, flowcharts, or test data
Furthermore, in geospatial queries, since SRID=0 is considered a planar Cartesian coordinate system without boundaries, the database cannot use predefined fine-grained grid subdivisions based on latitude and longitude ranges as it can for SRID=4326 (WGS 84). This lack of spatial index resolution leads to reduced filtering efficiency for SRID=0 indexes (producing excessive false positives), resulting in significantly lower query performance in high-concurrency or large-scale data scenarios compared to SRID=4326 data with the correct spatial reference system.