Skip to main content
edited title
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

How to define Defining layer style for KML layer within OGR Virtual Format?

Source Link
Simo A.
  • 213
  • 1
  • 6

How to define layer style for KML layer within OGR Virtual Format?

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.