[GIS] Export KML ExtendedData with OGR2OGR

gdalkmlogr2ogr

I would like to export with ogr2ogr the data I have in a kml as ExtendedData

        <Placemark>
        <ExtendedData>
            <SchemaData schemaUrl="#15540_punti">
                <SimpleData name="myid">9</SimpleData>
                <SimpleData name="IDENTITA">15540_IX</SimpleData>
                <SimpleData name="NOME">Fontana</SimpleData>
                <SimpleData name="AMP_CONO_V">80</SimpleData>
                <SimpleData name="PROF_1SSP">5,2</SimpleData>
                <SimpleData name="PROF_1P">26</SimpleData>
                <SimpleData name="PROF_2P">78</SimpleData>
                <SimpleData name="PROF_3P">156</SimpleData>
                <SimpleData name="PROF_SFOND">245.26</SimpleData>
                <SimpleData name="ASSE_DIR">117g39p8s</SimpleData>
                <SimpleData name="UNITA PAES">Piazza Santa Croce</SimpleData>
                <SimpleData name="QUOTA_SLM">276 + 1.50</SimpleData>
            </SchemaData>
        </ExtendedData>
        <Point>
            <coordinates>11.26078815736627,43.76921971994336,0</coordinates>
        </Point>
    </Placemark>
    <Placemark>

I have tried with gdal 1.9.2 and libkml to export in CSV, but I obtain a file that does not contain the fields of the original kml (myid, IDENTITA, NOME, etc.). This is the output

Name,description,timestamp,begin,end,altitudeMode,tessellate,extrude,visibility
,,,,,,-1,-1,-1
,,,,,,-1,-1,-1
,,,,,,-1,-1,-1
,,,,,,-1,-1,-1
,,,,,,-1,-1,-1
,,,,,,-1,-1,-1

Is it possible with ogr2ogr to export KML ExtendedData in tabular form?

Best Answer

There are limitations in ogr2ogr, as created shp will will have just 2 extra fields: Name and Description.

So you can specify to just 2 features to be writen. For ex. it might work to specify to write down ur first tag 'SimpleData name="myid"' (though not sure..):

ogr2ogr -f KML output.kml input.shp -dsco NameField= SimpleData name="myid"

The following creation options are supported:

NameField: Allows you to specify the field to use for the KML element. Default value : 'Name' ogr2ogr -f KML output.kml input.shp -dsco NameField=RegionName

DescriptionField: Allows you to specify the field to use for the KML element. Default value : 'Description'

http://www.gdal.org/ogr/drv_kml.html

Related Question