The SE_EnvelopeAsKML() function
The SE_EnvelopeAsKML() function takes a geometry value returned by ST_Envelope and returns it as a KML LatLonBox.
Syntax
SE_EnvelopeAsKML(p ST_Geometry)
Return type
ST_Geometry
Example
EXECUTE FUNCTION SE_EnvelopeAsKML(ST_PolyFromText(‘POLYGON
((-124.21160602 25.8373769872,
-67.1589579416 25.8373769872,
-67.1589579416 49.384359066,
-124.21160602 49.384359066,
-124.21160602 25.8373769872))',3));
Output:
<LatLonBox>
<north>49.384359066</north>
<south>25.8373769872</south>
<east>-67.1589579416</east>
<west>-124.21160602</west>
</LatLonBox>