On-the-Fly Spatial Analysis With PostGIS and Google Earth





Step 1: Download the database here
    Use the 'psql' command to load this database into your Postgres/PostGIS instance

Step 2: Download the classroom scripts here
    Unzip into your root webserver folder




Step 3: Load the following Layers Into Google Earth--
Wells
Pipelines
Land Grid


IMPORTANT: The data in the database only covers the state of Utah!





Task #1--Talk To Me

It Takes Two To Tango. The first thing we need to do is establish back and forth communication between Google Earth and the webserver. Google Earth is going to pass the center point and the bounding box using a Network Link and the <viewFormat> tag, pass it to a PHP page, and the PHP page is going to return KML.
Gotcha: Make sure the <viewRefreshMode> is set to onStop so the parameters are updated everytime the viewer moves.





Task #2--Stake Your Graphic Claim

The easiest way to make these parameters useful is to embed them as part of a hyperlink in the <Snippet> tag. That way you can send them to another page with the current screen info passed along.
Gotcha: It's important to send an HTTP header before your KML so the receiving machine knows to pipe the KML directly to Google Earth rather than to the browser itself.




Task #3--Freedom To Choose

For interactive analysis, hard-coding parameters will not get you very far. Adding in a rudimentary web form gives the user simple choice without a lot of complication.
Gotcha: You have to pass along the original center lat/long on to yet another server script.


Go To Next Section