KML to geojson with ogr2ogr not copying styles

1.3k views Asked by At

I am running the following command to convert a kml file to geojson:

$ ogr2ogr -f GeoJSON geojson.json doc.kml -nln test -append

In the KML styles look like this:

    <Document id="Point" xsi:schemaLocation="http://www.opengis.net/kml/2.2 http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd http://www.google.com/kml/ext/2.2 http://code.google.com/apis/kml/schema/kml22gx.xsd">
            <name>Point</name>
            <Snippet maxLines="0"></Snippet>
            <Style id="IconStyleOne">
                    <IconStyle>
                            <scale>0.8125</scale>
                            <Icon>
                                    <href>images/one.png</href>
                            </Icon>
                    </IconStyle>
                    <LabelStyle>
                            <color>00000000</color>
                            <scale>0</scale>
                    </LabelStyle>
                    <PolyStyle>
                            <color>ff000000</color>
                            <outline>0</outline>
                    </PolyStyle>
            </Style>
            <Style id="IconStyleTwo">
                    <IconStyle>
                            <Icon>
                                    <href>images/two.png</href>
                            </Icon>
                    </IconStyle>
                    <LabelStyle>
                            <color>00000000</color>
                            <scale>0</scale>
                    </LabelStyle>
                    <PolyStyle>
                            <color>ff000000</color>
                            <outline>0</outline>
                    </PolyStyle>
            </Style>

And the layer looks like this:

            <Folder id="FeatureLayer0">
                    <name>City</name>
                    <Snippet maxLines="0"></Snippet>
                    <Placemark id="ID_00000">
                            <name>NameOne</name>
                            <Snippet maxLines="0"></Snippet>
                            <description>Some desc</description>
                            <styleUrl>#IconStyleOne</styleUrl>
                            <Point>
                                    <coordinates>2,2,0</coordinates>
                            </Point>
                    </Placemark>

But when I convert the style is totally lost:

{
"type": "FeatureCollection",

"features": [
{ 
  "type": "Feature", 
  "properties": { 
    "Name": "NameOne",     
    "Description": "Some desc", 
    "geometry": { 
      "type": "Point", 
      "coordinates": [ 2, 2, 0.0 ] 
    } 
  }
}

Any way to get a reference to the style in the geojson?

0

There are 0 answers