[postgis-users] KML Export

Stefan Schwarzer stefan.schwarzer at grid.unep.ch
Wed Jul 15 00:44:47 PDT 2009


Ah, thanks a lot! That sounds great!

However, when inserting the function and executing this:

	SELECT askml('my_title', 'description', collect(the_geom)) FROM  
(SELECT c.the_geom FROM countries_view AS c) AS foo

I get this error:
	ERROR:  geometry_to_kml: 'GeometryCollection' geometry type not  
supported by Google Earth
	CONTEXT:  SQL function "askml" statement 1
	PL/pgSQL function "askml" line 21 at assignment
If I understand it correctly from this conversation, I'd need the  
latest version of Postgis to solve that issue, right?

Thanks for your valuable help,

Stefan

On Jul 14, 2009, at 5:50 PM, Kevin Neufeld wrote:

> As you've seen, there is the ST_AsKML command (http://postgis.refractions.net/documentation/manual-svn/ST_AsKML.html 
> ) that will convert a single geometry to KML.
>
> All you need to do is add some xml tags before the export geometry  
> tag and again after, closing the document.
>
> Here's an example of a simple wrapper that does this inside the  
> database, though you'd probably want to do this in PHP:
> http://lists.refractions.net/pipermail/postgis-users/attachments/20070914/7a02d424/askml.sql
>
> Example use case:
> SELECT askml('my_title', 'description', collect(the_geom))
> FROM my_spatial_table
> WHERE ....
>
> yields something like:
> <?xml version='1.0' encoding='UTF-8'?>
> <kml xmlns='http://earth.google.com/kml/2.1'>
> <Document>
> <name>'my_title'</name>
> <description>'description'</description>
>
> <Style id='defaultStyle'>
>  <LineStyle>
>    <color>ff00ff00</color>
>    <width>1</width>
>  </LineStyle>
>  <PolyStyle>
>    <color>5f00ff00</color>
>  </PolyStyle>
> </Style>
>
> <Placemark>
>  <styleUrl>#defaultStyle</styleUrl>
>  <MultiGeometry>
>    <Point>
>      <coordinates>-122.319,47.164</coordinates>
>    </Point>
>    <Point>
>      <coordinates>-122.272,47.067</coordinates>
>    </Point>
>  </MultiGeometry>
> </Placemark>
>
> </Document>
> </kml>
>
> Cheers,
> Kevin
>
>
>
> Stefan Schwarzer wrote:
>> Hi there,
>> I made a tour on Google to look around if there exist some KML  
>> export tool. I've seen the Set_AsKML command; I've seen this <http://postgis.refractions.net/pipermail/postgis-users/2007-September/017070.html 
>> > dicussion; and have found that someone wrote a script <http://postgis3d.blogspot.com/2007/12/googleearth-export.html 
>> > for postgis; and a phyton script <http://dev.riverchange.org/google_earth/genshi_template.kml 
>> >. But it seems that there is no easy-way-to-go export/wrapper  
>> script, enabling for example the execution of pgsql2kml...
>> Or can someone give be a hint how to develop a KML export for a PHP  
>> based Data Portal?
>> Thanks for any help,
>> Stef
>> ------------------------------------------------------------------------
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090715/ad702d13/attachment.html>


More information about the postgis-users mailing list