Wednesday, 4 October 2017

Defining 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:





wkbGeometryCollection
EPSG:4326



AMDT_02_2014_Finland_FIR.kml
SELECT *,'PEN(c:#FF00FF,w:10px)' AS OGR_STYLE FROM AMDT_02_2014_Finland_FIR



tsa2014.js
SELECT *,'PEN(c:#00FFFF,w:10px)' AS OGR_STYLE FROM OGRGeoJSON




ctr2014.js
SELECT *,'PEN(c:#FFFF00,w:5px)' AS OGR_STYLE FROM 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 SELECT *,'PEN(c:#FF00FF,w:10px)' AS OGR_STYLE FROM AMDT_02_2014_Finland_FIR 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.



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...