[gdal-dev] 2D KML to 3D KML

Brent Fraser bfraser at geoanalytic.com
Wed Sep 21 11:09:12 EDT 2011


Hi all,

   I've got some 2D KML generated by gdal_polygonize I'd like to turn 
into 3D KML.  Do you have any ogr2ogr techniques to do this?

A snip of my 2D KML:
------------------------------

<Placemark>
<name>1</name>
<Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
<ExtendedData><SchemaData schemaUrl="#out">
<SimpleData name="Name">1</SimpleData>
</SchemaData></ExtendedData>
<Polygon><outerBoundaryIs><LinearRing><coordinates>106.2125,-6.0 
106.2125,-6.01 106.225,-6.01 106.225,-6.02 106.2375,-6.02 106.2375,-6.03 
106.25,-6.03 106.25,-6.0 
106.2125,-6.0</coordinates></LinearRing></outerBoundaryIs></Polygon>
</Placemark
------------------------------
And the desired 3D KML:

<Placemark>
<name>1</name>
<Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>1</fill><color>ff0000ff</color></PolyStyle></Style>
<ExtendedData><SchemaData schemaUrl="#out">
<SimpleData name="Name">1</SimpleData>
</SchemaData></ExtendedData>
<Polygon>
<outerBoundaryIs><LinearRing><coordinates>106.2125,-6.0,101 
106.2125,-6.01,101 106.225,-6.01,101 106.225,-6.02,101 
106.2375,-6.02,101 106.2375,-6.03,101 106.25,-6.03,101 106.25,-6.0,101 
106.2125,-6.0,101 </coordinates></LinearRing></outerBoundaryIs></Polygon>
</Placemark>
------------------------------

I've added a "z" to the coordinates (100 plus the "name" value, to boost 
it above the terrain), plus a little bit of PolyStyle info to set the 
fill color.

The long term solution may be to enhance gdal_polygonize to output 3D 
vectors, but right now I'm just experimenting with visualizing KML in 
Google Earth....

-- 
Best Regards,
Brent Fraser




More information about the gdal-dev mailing list