PostGISGeometry Input

ST_GeomFromKML

What is ST_GeomFromKML?

ST_GeomFromKML parses a KML XML string and returns the PostGIS geometry. The output is always in EPSG:4326 because KML uses WGS84 exclusively.

SQL
ST_GeomFromKML(text kml)geometry

Supports KML Point, LineString, Polygon, and MultiGeometry elements including extended altitudes.

When would you use ST_GeomFromKML?

Use ST_GeomFromKML when ingesting Google Earth KML exports, KMZ unpacked contents, or government data delivered as KML. It is the simplest way to get KML feature geometry into PostGIS without round-tripping through GeoJSON or GML.

In interoperability pipelines that sync with Google Earth, KML is often the native exchange format; ST_GeomFromKML is the canonical reader.

FAQs

What SRID does the result have?

Always EPSG:4326. KML is WGS84-only by definition.

Does it parse altitudes?

Yes. KML altitude values are read as Z ordinates producing XYZ geometry.

Does it support KML network links or style?

No — only geometry elements are parsed. Styles, icons, and network links are ignored.

Can it read KMZ?

No. KMZ is a ZIP archive containing KML. Unzip first, then pass the KML contents to ST_GeomFromKML.