1

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

<OGRVRTDataSource>
  <OGRVRTUnionLayer name="union">

    <GeometryType>wkbGeometryCollection</GeometryType>
    <LayerSRS>EPSG:4326</LayerSRS>

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

    <OGRVRTLayer name="OGRGeoJSON">
      <SrcDataSource>tsa2014.js</SrcDataSource>
      <SrcSQL>SELECT *,'PEN(c:#00FFFF,w:10px)' AS OGR_STYLE FROM OGRGeoJSON</SrcSQL>
    </OGRVRTLayer>

    <OGRVRTLayer name="OGRGeoJSON">
      <SrcDataSource>ctr2014.js</SrcDataSource>
      <SrcSQL>SELECT *,'PEN(c:#FFFF00,w:5px)' AS OGR_STYLE FROM OGRGeoJSON</SrcSQL>
    </OGRVRTLayer>

  </OGRVRTUnionLayer>
</OGRVRTDataSource>

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.

0

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:

Styling

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.