Exporting Data from PostGIS to KML – How to Guide

kmlpostgis

What is the best way to export from PostGIS to KML using open source tools?

Can I do it directly, or do I need to first export to shape files?

Best Answer

You can use ogr2ogr to perform the operation:

 ogr2ogr -f "KML" mykml.kml PG:"host=myhost user=myloginname \ 
             dbname=mydbname password=mypassword" "myschema.mytable" \
             -s_srs EPSG:<myEPSGcode> -t_srs EPSG:4326