我正在运行以下命令将kml文件转换为geojson:
$ ogr2ogr -f GeoJSON geojson.json doc.kml -nln test -append
在KML样式中,如下所示:
<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>
图层看起来像这样:
<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>
但是当我转换时,风格完全丢失了:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"Name": "NameOne",
"Description": "Some desc",
"geometry": {
"type": "Point",
"coordinates": [ 2, 2, 0.0 ]
}
}
}
如何获得geojson中样式的引用?