Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if anyone knew a way to bring data from a postGIS database into Google earth to view live.

I know of the asKml function in PostGIS, but I'm interested to know if anyone had managed to hook up a kml so that it is live against the database and not just a static kml.

share|improve this question
per poster's request, google-earth tag added. – glennon Aug 5 '10 at 22:20
thanks :) I'm only 10 rep off being able to make new tags – Nathan W Aug 5 '10 at 22:24
up vote 8 down vote accepted

You can do it with GeoServer. Installing and "linking" Geoserver to Postgres/PostGIS database is quite easy.

KML KMZ Output

share|improve this answer
+1 What I like with geoserver is that you can do all the styling within the application and then all desired output will inherit the same styling be it kml/kmz, map tile (slippymap) or a WMS. – maning Aug 6 '10 at 8:19

This can be done by creating a Network Link KML, with the <refreshInterval> and <viewRefreshMode> (reference) settings set appropriately. As listed in the example, you'll need a script which returns the new response, in this case by sending the query down to PostGIS to respond with an updated asKml result.

share|improve this answer

The asKML function only returns the geometry in KML format - not the entire response. You will still need to write some sort of web service to create valid KML to return to the client.

It is not hard to do but you will need to write out all the XML required in the KML document. The nice part of the asKML function is you don't have to write all that tedious geometry xml tags.

Once you write the service then you can point google-earth at the URL for the service.

share|improve this answer

You can try FME Desktop or FME Server from Safe Software. If you are using FME Desktop you can schedule the translation from PostGIS to KML. The KML can be pushed to a FTP or a dropbox account directly by FME, so that everytime you have new data in PostGIS, the KML also gets re-written.Read more about dropbox and FME at

For some idea on FME Server and realtime KML look at this link:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.