Dynamic Export of Soil Survey Data to KML through Soil-Web

Submitted by dylan on Wed, 2007-05-16 22:00.

 
Overview
We have recently added a KML export function to our online soil survey (Soil-Web). The Google Earth icon is displayed at map scales of 1:35000 or larger, and clicking on it will create a KML file containing the SSURGO polygons within the current viewport. The KML file contains labeled centroids, with links to the map unit descriptions which are normally found on Soil-Web. You will need a current version of Google Earth in order to take advantage of the KML produced by our website.

To use this feature, zoom into a region of interest (at a scale of 1:35000 or larger) and click on the small Google Earth icon in the tool bar. If you have Google Earth installed, you may be prompted by the web browser software to open the resulting file directly in Google Earth. Optionally, download this KMZ file which can be used to seamlessly view soil survey content!



KML Export for Soil-WebKML Export for Soil-Web The small blue and white icon will export to KML

 
For large numbers of polygons expect about 2 seconds for KML file generation, with a size ranging from 1 - 4 MB.

 
Examples

2D polygons in Soil-Web: SSURGO polygons (yellow) as normally displayed in our online soil survey.2D polygons in Soil-Web: SSURGO polygons (yellow) as normally displayed in our online soil survey.

3D soil polygons as viewed in Google Earth: SSURGO polygons exported from our online soil survey to KML, and displayed in Google Earth.3D soil polygons as viewed in Google Earth: SSURGO polygons exported from our online soil survey to KML, and displayed in Google Earth.

 
Methods
All of the NCSS digital soil survey information on our site is stored in a PostGIS database, with geometry stored in a projected coordinate system (Albers Equal Area). The asKML() function found in PostGIS 1.2.1 makes converting our geometry to Google Earth compatible KML extremely simple- and it performs the required inverse projection on the fly! The general approach that we are using involves a series of steps, all of which are performed dynamically in PostGIS:

  1. select geometry overlapping the bounding box defined by the current viewport in AEA coordinates, using the PostGIS spatial indexing system
  2. compute the intersection between the boinding box and the overlapping polygons
  3. compute label locations for the new geometry
  4. convert the polygon geometry to KML
  5. convert the label geometry to KML
  6. add styling to the KML chunks with a PHP wrapper
  7. return a KML file to the browser, after setting the required headers:
    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Type: application/kml; charset=utf8");
    header('Content-Disposition: attachment; filename="ssurgo.kml"') ;

 
PHP is used to produce the final styled KML document, which is then returned to the browser. This file can be saved locally and opened with Google Earth. Note that KML can only be exported once you have zoomed in to at least a scale of 1:35000 or more.

 
Give it a try!

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <div> <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.