The ST_PolyFromKML() function

The ST_PolyFromKML() function takes a KML Polygon string representation and an optional spatial reference ID and returns a polygon object.

Syntax

ST_PolyFromKML(kmlstring lvarchar)
ST_PolyFromKML(kmlstring lvarchar, SRID integer)

Return type

ST_Polygon

Example

EXECUTE FUNCTION ST_PolyFromKML('<Polygon><outerBoundaryIs>
                 <LinearRing>
                 <coordinates>-122.365662,37.826988,0    
                 -122.365202,37.826302,0 -122.364581,37.82655,0
                 -122.365038,37.827237,0 -122.365662,37.826988,0 
                 </coordinates></LinearRing></outerBoundaryIs>
                 </Polygon>',4);
Output:
4 POLYGON Z ((-122.365662056 37.8269879529 0, -122.365202058 
              37.8263019779 0, -122.364580958 37.8265500822 0, 
              -122.36503794 37.827237063 0, -122.365662056 
              37.8269879529 0))