The spatial reference system (SRS) of spatial data is a coordinate-based geographic location system. OceanBase Database supports only the system default SRS.
Types of spatial reference systems
Spatial reference systems (SRSs) can be classified into the following types:
- Geographic SRSs. A geographic SRS is a non-projected SRS that represents the longitude-latitude or latitude-longitude coordinates on an ellipsoid, in any angular unit. It is based on the Earth's ellipsoid and uses degrees to represent coordinates. It is suitable for describing real-world geographic locations, such as GPS coordinates. For example, WGS 84 (SRID=4326) is a commonly used geographic SRS.
- Projected SRSs. A projected SRS is a projection of the ellipsoid onto a flat surface. It uses a Cartesian coordinate system and length units such as meters and feet. It is commonly used for displaying flat maps and performing spatial analysis.
In addition, OceanBase Database supports a special spatial reference system —— SRID 0. It 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. Notably, SRID 0 is the default SRID for spatial data. When using it, you must carefully distinguish its use from that of real-world geographic coordinate systems.
Obtain spatial reference system information
You can obtain information about the spatial reference systems built in the database by querying the INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS system table. For example, the definition of the SRS with 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.
Select an SRS
Correctly setting the SRID (spatial reference system identifier) is crucial for ensuring the accuracy of calculation results. Please select an SRS based on your data type.
We recommend that you use SRID=4326. Most geographic applications should use SRID=4326. SRID=4326 supports accurate distance, area, and buffer calculations and conforms to international standards. It is easy to integrate with other GIS systems. It is suitable for the following scenarios, for example:
- GPS coordinates (latitude and longitude)
- Coordinates returned by mobile location services and map APIs, such as those of Gaode, Google Maps, and Baidu Maps
- Geographic information, such as cities, roads, and points of interest (POIs)
We recommend that you use SRID=0 only when necessary. SRID=0 indicates "no coordinate system". All calculations are performed in a pure mathematical plane, and the results have no geographic meaning.
Warning
Do not set real latitude and longitude data to SRID=0. Otherwise, the results of distance and area analysis will be severely incorrect.
SRID=0 is suitable only for scenarios where the data does not represent real-world locations on Earth, such as the following scenarios:
- Coordinates in game maps and virtual scenes
- Coordinates in CAD engineering drawings and architectural floor plans, which are local coordinate systems
- Abstract charts, flowcharts, and test data
In addition, 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 the latitude and longitude ranges as it does for SRID=4326 (WGS 84). The lack of spatial index resolution results in a decrease in the index filtering efficiency of SRID=0 (a large number of false positives), which significantly reduces the query performance of SRID=0 in high-concurrency or large-scale data scenarios compared to that of SRID=4326 data configured with the correct spatial reference system.