I am exporting a layer from PostgreSQL to KML using ogr2ogr
.
I get a workable KML with a series of features (Placemarks). Here is a simplified example of a feature. (I took out the long list of polygon points to simplify the length of the geometry).
<Placemark>
<name>FirstFeature</name>
<description>A map feature</description>
<Style>
<LineStyle>
<color>ff0000ff</color>
</LineStyle>
<PolyStyle>
<fill>0</fill>
</PolyStyle>
</Style>
<ExtendedData>
<SimpleData name="MapUnit">myunit</SimpleData>
<SimpleData name="hexcolor">ffe9e9e9</SimpleData>
</ExtendedData>
<MultiGeometry>
<Polygon><outerBoundaryIs><LinearRing>
<coordinates>[array of coordinates]</coordinates>
</LinearRing></outerBoundaryIs></Polygon>
</MultiGeometry>
</Placemark>
I would like to set the layer creation options such that it will refer to the 8bit hex-code provided by the hexcolor attribute. By default, ogr2ogr seems to be styling all polygon features as red lines with transparent fill (see above <Style></Style>
). I instead want the style such that the <Style></Style>
section becomes...
<Style>
<LineStyle>
<color>ff0000ff</color>
</LineStyle>
<PolyStyle>
<color>ffe9e9e9</color> <!--Taken from the hexcolor attribute-->
<fill>1</fill>
</PolyStyle>
</Style>