I have the following OGR virtual format data source, which includes a few GeoJSON files and one KML file:

  <OGRVRTUnionLayer name="union">


    <OGRVRTLayer name="AMDT_02_2014_Finland_FIR">
      <SrcSQL>SELECT *,'PEN(c:#FF00FF,w:10px)' AS OGR_STYLE FROM AMDT_02_2014_Finland_FIR</SrcSQL>

    <OGRVRTLayer name="OGRGeoJSON">

    <OGRVRTLayer name="OGRGeoJSON">


Setting the layer style for the GeoJSON layers works fine when doing a ogr2ogr conversion to another format such as PDF. However, trying to set the KML layer style with <SrcSQL>SELECT *,'PEN(c:#FF00FF,w:10px)' AS OGR_STYLE FROM AMDT_02_2014_Finland_FIR</SrcSQL> seems to have no effect. Default black pen is used to draw the polygon outline:

Example output of the three layers

Is there a way to change the style of a KML layer within OGR VRT file? At least the syntax above does not seem to work.

The KML file used in this question can be downloaded from Dropbox.


I fear you are out of luck with your current approach because this sentence from the GDAL wiki http://trac.osgeo.org/gdal/wiki/KML makes me understand that the GDAL KML driver does not support OGR Styles:


Until the driver supports the OGR simple feature style...

The same wiki page gives advice for styling KML with XLS stylesheet. Consider to make a feature request about adding OGR_STYLE support for the KML driver into GDAL issue tracker http://trac.osgeo.org/gdal/. Check the old tickets first, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.