Skip to main content
Every geometric shape has a spatial reference system associated with it, and each such reference system has a Spatial Reference System ID (). The SRID is used to tell which spatial reference system will be used to interpret each spatial object. A common SRID in use is 4326, which represents spatial data using longitude and latitude coordinates on the Earth’s surface as defined in the standard, which is also used for the Global Positioning System (GPS). Here is an example shape that uses SRID 4326, a line stretching from Milwaukee, WI to Tulsa, OK:
Most users should only have to care about SRIDs in the following situations:
  • When creating shapes. By default, shapes which do not have an SRID associated with them will use an SRID of 0, which means “this shape has no SRID”.
  • When comparing shapes. If you try to compare two shapes with different SRIDs using a spatial predicate, CockroachDB will signal an error.

Adding SRIDs to shapes

Add an SRID with WKT

To add an SRID to a shape you are defining with , prepend the text with SRID=N; as shown below:

Add an SRID with SQL

To add an SRID to a shape in SQL, use the ST_SetSRID :

Change a shape’s SRID

To convert a shape to use a different SRID while maintaining the same reference location, use the ST_Transform function. In the example below, we transform the reference system for a line from Albany, NY to Saranac Lake, NY from 4326 to use the StatePlane New York East reference (SRID 3101). This can be useful (or at least interesting) in some situations, since the StatePlane systems give distances in feet.
When setting a shape’s SRID, you can only use SRIDs that are defined in the table. For more information, see Getting SRID information.

Getting SRID information

You can get more detailed information about the SRIDs supported in CockroachDB from the by querying the table. To see how many SRIDs are supported, run the following query:
To get more information about a specific SRID (in this case 4326), run the following query:

Comparing shapes with different SRIDs

If you try to compare two shapes with different SRIDs using a spatial predicate, CockroachDB will signal an error:

Known limitations

Defining a custom SRID by inserting rows into is not currently supported.

See also