[Gdal-dev] KML with descriptions from Postgis Views via ogr2ogr

Andreas Neumann a.neumann at carto.net
Mon Feb 2 03:49:53 EST 2009

Hi Georges,

I usually generate my KML files with a scripting language like PHP or
Perl. It gives you more fine-grained control over the structure and
content of the KML as opposed to "automatic" conversions like ogr2ogr or

It might be useful to post your KML somewhere if you want to have comments.

The KML tutorials at Google might be useful to get more insight on what
might be wrong with your KML:

also contains a KML reference.

If you want I can send you PHP examples how I generate polygons to KML
from Postgis. It is actually quite simple, since Postgis already offers
the AsKML() command for converting the geometry.


> I'm really impressed by the command-line functionality of ogr2ogr, since
> I've
> found until now no suitable gui to use it under Windows.
> Actually I try to create KML-files from Postgressql/Postgis-data with
> ogr2ogr, which works fine. I encountered only two problems, that I
> couldn't
> solve until now. Maybe there is someone that can help me.
> My command looks like this:
> ogr2ogr -f KML c:/parzellen.kml PG:"host=localhost port=5432 dbname=test
> user=postgres password=XXXX" -sql "select ka_nr, ka_sect as Sektion,
> ka_flur
> as Flur, ka_akte as Kaufakte, kart_dat as Kartierdatum, kart_pers as
> Kartierer, pacht as Pächter, transform(the_geom,4326) from view_kataster"
> -dsco NameField=kadaster_nr -dsco
> DescriptionField=Sektion,Flur,Kaufakte,Kartierdatum,Kartierer,Pächter
> My main problem is, that the kml-file is created, but doesn't display at
> the
> right place in Google Earth. When opening the file in GE first GE zooms
> close to the place, where the polygons should be. When I click in GE on
> the
> imported layer, all the polygons are there, but they are displayed as
> point
> marker??? When I click them, I get a balloon, with only a part of the
> informations I wanted to be displayed. The main problem is, that the
> balloons sit 'lost in space', meens outside the earth somewhere in space
> ??
> When i hover the balloons with the mouse, the displayed lat and lon, and
> hight values are OK.
> I've tried to indicate the source and the target projection with -s_srs
> "EPSG:2169" or -t_srs "EPSG:4326", but without other results.
> The underlying table works fine, so maybe there is a problem with using
> views in ogr2ogr???
> The other problem is, that the kml-file only contains the NameField and
> the
> 3 first DescriptionFields (Sektion,Flur,Kaufakte), the rest is ignored.
> Are
> there any restrictions I've ignored?
> Maybe there is someone, who could give me an a tip or an answer to my
> questions?
> --
> View this message in context:
> http://n2.nabble.com/KML-with-descriptions-from-Postgis-Views-via-ogr2ogr-tp2255911p2255911.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

Andreas Neumann
Böschacherstrasse 6, CH-8624 Grüt/Gossau, Switzerland
Email: a.neumann at carto.net, Web:
* http://www.carto.net/ (Carto and SVG resources)
* http://www.carto.net/neumann/ (personal page)
* http://www.svgopen.org/ (SVG Open Conference)
* http://www.geofoto.ch/ (Georeferenced Photos of Switzerland)

More information about the gdal-dev mailing list