Is there 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 it's possible to dynamically load KML-formatted data from PostGIS into Google Earth.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
This can be done by creating a Network Link KML, with the
<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
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.
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 evangelism.safe.com/fmeevangelist52/
For some idea on FME Server and realtime KML look at this link: http://www.fmepedia.com/index.php/Real-time_Taxi_Cabs_(KML_Network_Link_Example)