Units of measure
Units of measure define the conversion factor between meters and other units.
You include the unit of measure information when you calculate distance or area for geometries that have angular units with the following functions:
- ST_Area()
- ST_Buffer()
- ST_Distance()
- ST_Length()
- ST_Perimeter()
Include the appropriate value from the unit_name column of the st_units_of_measure table when you run the function.
You can also use units of measure in your applications when you need to convert between units.
To create a new unit of measure, insert a row into the st_units_of_measure table. Specify values for the following columns:
- unit_name: The name of the unit of measure. Must be unique and cannot exceed 128 characters.
- unit_type: The measurement type. Can be
linear
orangular
. - conversion_factor: The conversion factor between the unit of measure and 1 meter. A double precision number that is > 0.0.
- description: Optional. The description of the unit of measure. Cannot exceed 255 characters.
Example
The following statement creates a linear unit of measure that is named half_meter and has a conversion factor of .5:
INSERT INTO sde.st_units_of_measure
VALUES('half_meter','linear',.5,'test uom');
Compare the results of the following two queries. The following query returns the length of a linestring in meters:
EXECUTE FUNCTION round(st_length
('32605 linestring(503208 43653, 503210 43653)'::st_linestring,
'meter'),2);
(expression)
2.00000000000000
1 row(s) retrieved.
The following query returns the length of the same linestring in half-meter units:
EXECUTE FUNCTION round(st_length
('32605 linestring(503208 43653, 503210 43653)'::st_linestring,
'half_meter'),2);
(expression)
4.00000000000000
1 row(s) retrieved.