[postgis-users] AsKML() how to create kml from postgis data

Kevin Neufeld kneufeld at refractions.net
Fri Sep 14 16:03:34 PDT 2007


Absolutely.

See attached, a simple plpgsql function that adds header info around the 
current askml function.

I do this in psql:
-- Set output to unaligned
\a

-- Show only tuples
\t

-- Dump query to a file
\o my_kml_file.kml

-- Run your query
SELECT askml('my_line', 'description', 'SRID=3005;LINESTRING( 1190000 
390000, 1200000 390000, 1200000 380000, 1190000 380000, 1190000 390000 
)'::geometry);

-- Flush output your file and close the output stream
\o

Loading this file in Google Earth will draw a box around Victoria, BC.

I often collect() geometries from a table and pass those into this function:
SELECT askml('my_title', 'description', collect(the_geom)) FROM my_line 
table WHERE ....

Cheers,
Kevin

-------------
Kevin Neufeld
Software Developer
Refractions Research Inc.
300-1207 Douglas St.
Victoria, B.C., V8W 2E7

Phone: (250) 383-3022
Email: kneufeld at refractions.net



Maciej Skorczewski wrote:
> hi all!
>
>
> How should i use AsKML() function to create KML files (w try show 
> postgis data in google maps nad google earth)
>
> It is posible?
>
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: askml.sql
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070914/7a02d424/attachment.ksh>


More information about the postgis-users mailing list