The SE_CreateSRID() function

The SE_CreateSRID() function is a utility function that, given the X and Y extents of a spatial data set, computes the false origin and system units and creates a new entry in the spatial_references table. Appropriate offsets and scale factors for typical Z values and M values are also provided.

Syntax

Use the following syntax to create a spatial reference system that is based on an existing spatial reference system that is not listed in the spatial_references table:

SE_CreateSRID (factory_id integer,
               type varchar(64) default NULL,
               description varchar(64) default NULL,
               SRID integer default NULL)
Table 1. Options for the SE_CreateSRID() function

Parameter Description
factory_id The ESRI Projection Engine ID number of an existing spatial reference system that is not listed in the spatial_references table on which to base the new spatial reference system.

If the factory_id is the same as an SRID in the spatial_references table, an error is returned.

type The type of coordinate system:
  • projcs: Default. Projected coordinate system.
  • geogcs: Geographic coordinate system.
description Your description of the spatial reference system.

Default is 'auth_name auth_srid auth_version', where auth_name is the authority name, auth_srid is the factory ID, and auth_version is the version number that is associated with the factory ID.

SRID The new SRID.

Default is the same value as the factory_id parameter.

Use the following syntax to create a spatial reference system by specifying X and Y extents:

SE_CreateSRID (xmin float, ymin float,
               xmax float, ymax float,
               description varchar(64))
Table 2. Options for the SE_CreateSRID() function

Parameter Description
xmin The minimum value of the x-coordinate
ymin The minimum value of the y-coordinate
xmax The maximum value of the x-coordinate
ymax The maximum value of the y-coordinate
description Your description of the spatial reference system

Usage

The spatial_references table holds data about spatial reference systems. A spatial reference system is a description of a coordinate system for a set of geometric objects; it gives meaning to the X and Y values that are stored in the database.

You need to specify an SRID of a spatial reference system when you load spatial data into a database because the database server translates and scales each floating point coordinate of the geometry into a 53-bit positive integer before storage.

The spatial_references table is pre-loaded with an entry for SRID=0, which is suitable for worldwide spatial data in latitude/longitude format.

If SRID=0 is not suitable for your data, you can run the SE_CreateSRID() function to create a more appropriate spatial_references table entry. However, because the SE_CreateSRID() function only considers the X and Y extents of your data, it might not create sufficiently refined parameters to describe the spatial reference system that you need. You can use an INSERT statement to specify false origin and system units instead of allowing the database server to calculate the values.

The spatial_references table contains many predefined spatial reference systems. If the predefined spatial reference systems are not suitable for your data, you can run the SE_CreateSRID() function to create a more appropriate spatial_references table entry. You can base your system on an existing spatial reference system that is not already in the spatial_references table or you can specify the X and Y extents of your data. If you specify the X and Y extent data, the database server calculates the value for the false origin and system units. Therefore, the SE_CreateSRID() function might not create sufficiently refined parameters to describe the spatial reference system that you need. You can use an INSERT statement to specify false origin and system units.

Return type

Returns the SRID of a newly created spatial_references table entry as an integer.

Example: Create an SRID by specifying X and Y extents

The following example creates an entry in the spatial_references table that is suitable for spatial data in New Zealand and returns the assigned SRID of 1001:
EXECUTE FUNCTION SE_CreateSRID (166, -48, 180, -34,
                                "New Zealand: lat/lon coords");

(expression) 

        1001
The following query shows the resulting spatial_references table entry:
SELECT * FROM spatial_references WHERE srid = 1001;


srid         1001
description  New Zealand: lat/lon coords
auth_name    
auth_srid    
falsex       164.6000000000
falsey       -49.4000000000
xyunits      127826407.5600
falsez       -1000.00000000
zunits       1000.000000000
falsem       -1000.00000000
munits       1000.000000000
srtext       UNKNOWN

Example: Create a spatial reference system that is a copy of an existing system

The following statement creates a spatial reference system with an SRID of 1002 that is based on the EPSG coordinate system that has a factory ID of 4326:

EXECUTE FUNCTION SE_CreateSrid(4326, 'projcs', 'WGS 1984', 1002);

(expression)

        1002

The following statement shows the properties of SRID 1002:

SELECT * FROM spatial_references WHERE srid = 1002;


srid         1002
description  WGS 1984
auth_name    EPSG
auth_srid    4326
falsex       -216.000000000
falsey       -126.000000000
xyunits      20849998274900
falsez       -1000.00000000
zunits       1000.000000000
falsem       -1000.00000000
munits       1000.000000000
srtext       GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",63781
             37.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.01745
             32925199433]]

1 row(s) retrieved.

Example: Add an existing spatial reference system

The following statement shows the OGC well-known text representation of an existing spatial reference system that has a factory ID of 3000. This factory ID is not listed in the spatial_reference table by default.

EXECUTE FUNCTION SE_CreateSrtext(3000); 


(expression)  PROJCS["Gunung_Segara_NEIEZ",GEOGCS["GCS_Gunung_Segara",DATUM["D_ 
             Gunung_Segara",SPHEROID["Bessel_1841",6377397.155,299.1528128]],P 
             RIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECT 
             ION["Mercator"],PARAMETER["False_Easting",3900000.0],PARAMETER["F 
             alse_Northing",900000.0],PARAMETER["Central_Meridian",110.0],PARA 
             METER["Standard_Parallel_1",4.45405154589751],UNIT["Meter",1.0]] 

1 row(s) retrieved.) 

The following statement adds the factory ID 3000 to the spatial_reference table. Because an SRID is not specified, by default, the SRID is the same as the factory ID:

EXECUTE FUNCTION SE_CreateSrid(3000); 

(expression) 

       3000 

1 row(s) retrieved. 

The following statement shows the properties of SRID 3000:

SELECT * FROM spatial_references WHERE srid = 3000; 


srid         3000 
description  EPSG 3000, version 8.1.1 
auth_name    EPSG 
auth_srid    3000 
falsex       -22096080.0000 
falsey       -35225280.0000 
xyunits      124666151.4420 
falsez       -1000.00000000 
zunits       1000.000000000 
falsem       -1000.00000000 
munits       1000.000000000 
srtext       PROJCS 

1 row(s) retrieved.