# ST_CREATE_SRS procedure

Use the ST_CREATE_SRS stored procedure to create a spatial reference system.

A spatial reference system is defined by the coordinate system, the precision, and the extents of coordinates that are represented in this spatial reference system. The extents are the minimum and maximum possible coordinate values for the X, Y, Z, and M coordinates.

Internally, Db2® Spatial Extender stores the coordinate values as positive integers. Thus during computation, the impact of rounding errors (which are heavily dependent on the actual value for floating-point operations) can be reduced. Performance of the spatial operations can also improve significantly.

- The first variation takes the conversion factors (offsets and scale factors) as input parameters.
- The second variation takes the extents and the precision as input parameters and calculates the conversion factors internally.

## Authorization

None required.

## Syntax

- With conversion factors (version 1)
- With maximum possible extend (version 2)

## Parameter descriptions

- With conversion factors (version 1)
- srs_name
- Identifies the spatial reference system. You must specify a non-null
value for this parameter.
The srs_name value is converted to uppercase unless you enclose it in double quotation marks.

The data type of this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).

- srs_id
- Uniquely identifies the spatial reference system.
This numeric identifier is used as an input parameter for various
spatial functions. You must specify a non-null value for this parameter.
The data type of this parameter is INTEGER.

- x_offset
- Specifies the offset for all X coordinates of geometries that
are represented in this spatial reference system. The offset is subtracted
before the scale factor x_scale is applied
when geometries are converted from external representations (WKT,
WKB, shape) to the Db2 Spatial Extender internal representation. (
*WKT*is well-known text, and*WKB*is well-known binary.) Although you must specify a value for this parameter, the value can be null. If this parameter is null, a value of 0 (zero) is used.The data type of this parameter is DOUBLE.

- x_scale
- Specifies the scale factor for all X coordinates of geometries
that are represented in this spatial reference system. The scale factor
is applied (multiplication) after the offset x_offset is subtracted when geometries are converted from external
representations (WKT, WKB, shape) to the Db2 Spatial Extender internal representation. Either the x_offset value is specified explicitly, or a default x_offset value of 0 is used. You must specify a non-null
value for this parameter.
The data type of this parameter is DOUBLE.

- y_offset
- Specifies the offset for all Y coordinates of geometries that
are represented in this spatial reference system. The offset is subtracted
before the scale factor y_scale is applied
when geometries are converted from external representations (WKT,
WKB, shape) to the Db2 Spatial Extender internal representation. Although you must specify a value
for this parameter, the value can be null. If this parameter is the
null value, a value of 0 (zero) is used.
The data type of this parameter is DOUBLE.

- y_scale
- Specifies the scale factor for all Y coordinates of geometries
that are represented in this spatial reference system. The scale factor
is applied (multiplication) after the offset y_offset is subtracted when geometries are converted from external
representations (WKT, WKB, shape) to the Db2 Spatial Extender internal representation. Either the y_offset value is specified explicitly, or a default y_offset value of 0 is used. Although you must specify
a value for this parameter, the value can be null. If this parameter
is null, the value of the x_scale parameter
is used. If you specify a value other than null for this parameter,
the value that you specify must match the value of the x_scale parameter.
The data type of this parameter is DOUBLE.

- z_offset
- Specifies the offset for all Z coordinates of geometries that
are represented in this spatial reference system. The offset is subtracted
before the scale factor z_scale is applied
when geometries are converted from external representations (WKT,
WKB, shape) to the Db2 Spatial Extender internal representation. Although you must specify a value
for this parameter, the value can be null. If this parameter is null,
a value of 0 (zero) is used.
The data type of this parameter is DOUBLE.

- z_scale
- Specifies the scale factor for all Z coordinates of geometries
that are represented in this spatial reference system. The scale factor
is applied (multiplication) after the offset z_offset is subtracted when geometries are converted from external
representations (WKT, WKB, shape) to the Db2 Spatial Extender internal representation. Either the z_offset value is specified explicitly, or a default z_offset value of 0 is used. Although you must specify
a value for this parameter, the value can be null. If this parameter
is null, a value of 1 is used.
The data type of this parameter is DOUBLE.

- m_offset
- Specifies the offset for all M coordinates of geometries that
are represented in this spatial reference system. The offset is subtracted
before the scale factor m_scale is applied
when geometries are converted from external representations (WKT,
WKB, shape) to the Db2 Spatial Extender internal representation. Although you must specify a value
for this parameter, the value can be null. If this parameter is null,
a value of 0 (zero) is used.
The data type of this parameter is DOUBLE.

- m_scale
- Specifies the scale factor for all M coordinates of geometries
that are represented in this spatial reference system. The scale factor
is applied (multiplication) after the offset m_offset is subtracted when geometries are converted from external
representations (WKT, WKB, shape) to the Db2 Spatial Extender internal representation. Either the m_offset value is specified explicitly, or a default m_offset value of 0 is used. Although you must specify
a value for this parameter, the value can be null. If this parameter
is null, a value of 1 is used.
The data type of this parameter is DOUBLE.

- coordsys_name
- Uniquely identifies the coordinate system on which this spatial
reference system is based. The coordinate system must be listed in
the view ST_COORDINATE_SYSTEMS. You must supply a non-null value for
this parameter.
The coordsys_name value is converted to uppercase unless you enclose it in double quotation marks.

The data type of this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).

- description
- Describes the spatial reference system by explaining the application's
purpose. Although you must specify a value for this parameter, the
value can be null. If this parameter is null, no description information
is recorded.
The data type of this parameter is VARCHAR(256).

- With maximum possible extend (version 2)
- srs_name
- Identifies the spatial reference system. You must specify a non-null
value for this parameter.
The srs_name value is converted to uppercase unless you enclose it in double quotation marks.

The data type of this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).

- srs_id
- Uniquely identifies the spatial reference system. This numeric
identifier is used as an input parameter for various spatial functions.
You must specify a non-null value for this parameter.
The data type of this parameter is INTEGER.

- x_min
- Specifies the minimum possible X coordinate value for all geometries
that use this spatial reference system. You must specify a non-null
value for this parameter.
The data type of this parameter is DOUBLE.

- x_max
- Specifies the maximum possible X coordinate value for all geometries
that use this spatial reference system. You must specify a non-null
value for this parameter.
Depending on the value of x_scale, the value that is shown in the view DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS might be larger than the value that is specified here. The value from the view is correct.

The data type of this parameter is DOUBLE.

- x_scale
- Specifies the scale factor for all X coordinates of geometries
that are represented in this spatial reference system. The scale factor
is applied (multiplication) after the offset x_offset is subtracted when geometries are converted from external
representations (WKT, WKB, shape) to the Db2 Spatial Extender internal representation. The calculation of the offset x_offset is based on the x_min value. You must supply a non-null value for this parameter.
If both the x_scale and y_scale parameters are specified, the values must match.

The data type of this parameter is DOUBLE.

- y_min
- Specifies the minimum possible Y coordinate value for all geometries
that use this spatial reference system. You must supply a non-null
value for this parameter.
The data type of this parameter is DOUBLE.

- y_max
- Specifies the maximum possible Y coordinate value for all geometries
that use this spatial reference system. You must supply a non-null
value for this parameter.
Depending on the value of y_scale, the value that is shown in the view DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS might be larger than the value that is specified here. The value from the view is correct.

The data type of this parameter is DOUBLE.

- y_scale
- Specifies the scale factor for all Y coordinates of geometries
that are represented in this spatial reference system. The scale factor
is applied (multiplication) after the offset y_offset is subtracted when geometries are converted from external
representations (WKT, WKB, shape) to the Db2 Spatial Extender internal representation. The calculation of the offset y_offset is based on the y_min value. Although you must specify a value for this parameter,
the value can be null. If this parameter is null, the value of the x_scale parameter is used. If both the y_scale and x_scale parameters
are specified, the values must match.
The data type of this parameter is DOUBLE.

- z_min
- Specifies the minimum possible Z coordinate value for all geometries
that use this spatial reference system. You must specify a non-null
value for this parameter.
The data type of this parameter is DOUBLE.

- z_max
- Specifies the maximum possible Z coordinate value for all geometries
that use this spatial reference system. You must specify a non-null
value for this parameter.
Depending on the value of z_scale, the value that is shown in the view DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS might be larger than the value that is specified here. The value from the view is correct.

The data type of this parameter is DOUBLE.

- z_scale
- Specifies the scale factor for all Z coordinates of geometries
that are represented in this spatial reference system. The scale factor
is applied (multiplication) after the offset z_offset is subtracted when geometries are converted from external
representations (WKT, WKB, shape) to the Db2 Spatial Extender internal representation. The calculation of the offset z_offset is based on the z_min value. Although you must specify a value for this parameter,
the value can be null. If this parameter is null, a value of 1 is
used.
The data type of this parameter is DOUBLE.

- m_min
- Specifies the minimum possible M coordinate value for all geometries
that use this spatial reference system. You must specify a non-null
value for this parameter.
The data type of this parameter is DOUBLE.

- m_max
- Specifies the maximum possible M coordinate value for all geometries
that use this spatial reference system. You must specify a non-null
value for this parameter.
Depending on the value of m_scale, the value that is shown in the view DB2GSE.ST_SPATIAL_REFERENCE_SYSTEMS might be larger than the value that is specified here. The value from the view is correct.

The data type of this parameter is DOUBLE.

- m_scale
- Specifies the scale factor for all M coordinates of geometries
that are represented in this spatial reference system. The scale factor
is applied (multiplication) after the offset m_offset is subtracted when geometries are converted from external
representations (WKT, WKB, shape) to the Db2 Spatial Extender internal representation. The calculation of the offset m_offset is based on the m_min value. Although you must specify a value for this parameter,
the value can be null. If this parameter is null, a value of 1 is
used.
The data type of this parameter is DOUBLE.

- coordsys_name
- Uniquely identifies the coordinate system on which this spatial
reference system is based. The coordinate system must be listed in
the view ST_COORDINATE_SYSTEMS. You must specify a non-null value
for this parameter.
The coordsys_name value is converted to uppercase unless you enclose it in double quotation marks.

- description
- Describes the spatial reference system by explaining the application's
purpose. Although you must specify a value for this parameter, the
value can be null. If this parameter is null, no description information
is recorded.
The data type of this parameter is VARCHAR(256).

## Output parameters

- msg_code
- Specifies the message code that is returned from the stored procedure.
The value of this output parameter identifies the error, success,
or warning condition that was encountered during the processing of
the procedure. If this parameter value is for a success or warning
condition, the procedure finished its task. If the parameter value
is for an error condition, no changes to the database were performed.
The data type of this output parameter is INTEGER.

- msg_text
- Specifies the actual message text, associated with the message
code, that is returned from the stored procedure. The message text
can include additional information about the success, warning, or
error condition, such as where an error was encountered.
The data type of this output parameter is VARCHAR(1024).