I am trying to figure out how to use GDAL (ogr2ogr) to export spatial data from SQLServer to KML. The standard KML driver works, but it is not very robust. LIBKML has so much promise (layers, styling, etc), but I cannot find any examples of how to make use of this added functionality.

For example, this works:

ogr2ogr.exe -f LIBKML z.kml "MSSQL:server=box;database=main;trusted_conneciton=yes;tables=dbo.z" -where "state='DE'"

It exports a POINT from my table. I would like to customize labels, icons (color, scale and image) and balloon text. I would also like to create folders/layers.

Ideally, I'd love to use columns like "icon_scale" and "layer_name" in my source tables to control this customization ...

Can you provide an example?

closed as off-topic by PolyGeo Feb 6 '18 at 5:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I have figured this much out ... my table (in the above example = dbo.z) needs a column named OGR_STYLE and contains something like this: SYMBOL(id:"http://www.example.com/icon.png",c:#ffff00ff,s:0.5) This allow me to set the image, color and size. See gdal.org/ogr_feature_style.html for more info. I still haven't quite figured out how to set the LABEL and would love an example of something that works that sets both SYMBOL and LABEL while using OGR2OGR. – dfmurphy Apr 10 '15 at 18:14
  • To set label/name, you can append -dsco NameField=<here comes the name of your column for label>. – mlt May 28 '15 at 1:18

Browse other questions tagged or ask your own question.