Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This question already has an answer here:

I am trying to import a KML file to QGIS. The KML source file is about 15mb is comprised of polygons with attribute data. The KML imports fine and polygons display but the attribute data is unreadable - all contained within [Description] field but looks like this:

"<br><br><br>
<table border="1" padding="0">
<tr><td>ID_INT</td><td>NGA0104001</td></tr>
<tr><td>N_sd</td><td>Igbere</td></tr>
<tr><td>Skm2</td><td>3.34</td></tr>
<tr><td>PT2010</td><td>13000</td></tr>"

As I understand it the conversion is handled by GDAL. I'm running QGIS v.1.8 on Ubuntu 12.04, but have built GDAL library 1.10.1 against the libkml library. Even if I attempt to convert to shapefile using the command line ogr2ogr method I still get the description field parsed incorrectly.

I've tried various on-line tools (e.g.http://www.zonums.com/online/kml2shp.php) but my file is too large or description field comes out as above.

As anyone had any success with converting kml to shape and retaining attribute data. I've found the pykml (http://pythonhosted.org/pykml/index.html) library and have been experimenting with it using ipython notebook to see if I could write the kml to a csv file but equally no joy:(

Any help greatly appreciated!

Marty

p.s. the KML is too large to post but here's what it looks like:

        <?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
    <Document>
    <name>AFNGA_SWAC.kml</name>
    <open>1</open>
    <Style id="s_ylw-pushpin1">
        <IconStyle>
            <scale>1.1</scale>
            <Icon>
                <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
            </Icon>
            <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
        </IconStyle>
        <LineStyle>
            <color>ff00ffff</color>
            <width>3</width>
        </LineStyle>
        <PolyStyle>
            <color>3300ffff</color>
        </PolyStyle>
    </Style>
    <StyleMap id="m_ylw-pushpin1">
        <Pair>
            <key>normal</key>
            <styleUrl>#s_ylw-pushpin1</styleUrl>
        </Pair>
        <Pair>
            <key>highlight</key>
            <styleUrl>#s_ylw-pushpin_hl1</styleUrl>
        </Pair>
    </StyleMap>
    <Style id="s_ylw-pushpin_hl1">
        <IconStyle>
            <scale>1.3</scale>
            <Icon>
                <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
            </Icon>
            <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
        </IconStyle>
        <LineStyle>
            <color>ff00ffff</color>
            <width>3</width>
        </LineStyle>
        <PolyStyle>
            <color>3300ffff</color>
        </PolyStyle>
    </Style>
    <Folder>
        <name>AFNGA_SWAC</name>
        <open>1</open>
        <description>1027 Éléments de la couche Afnga_swac</description>
        <Placemark>
            <name>Aba</name>
            <description><![CDATA[<br><br><br>
    <table border="1" padding="0">
    <tr><td>ID_INT</td><td>NGA0101001</td></tr>
    <tr><td>N_sd</td><td>Aba</td></tr>
    <tr><td>Skm2</td><td>384.07</td></tr>
    <tr><td>PT2010</td><td>1010000</td></tr>]]></description>
            <styleUrl>#m_ylw-pushpin1</styleUrl>
            <Polygon>
                <extrude>1</extrude>
                <tessellate>1</tessellate>
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
                            7.294567000000001,5.00267,0 7.294408999999999,5.002552,0 7.294211,5.002394,0
share|improve this question

marked as duplicate by Get Spatial, Fezter, Curlew, whuber Nov 15 '13 at 15:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
maybe you could try using the command line version of ogr2ogr? this is the gdal tool for converting vector data into other vector formats. see gdal.org/ogr2ogr.html –  Jens Nov 15 '13 at 7:27

1 Answer 1

It looks like it's importing perfectly fine, and the 'description' field contains HTML.

share|improve this answer
1  
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. –  Zachary Sep 5 '13 at 12:38
    
Zachary: I humbly disagree. The answer is that it is working fine and as expected. –  Darren Cope Sep 5 '13 at 12:55
    
Thanks for the comments guys. Darren, I realise that its dumping HTML into the description field, but is this really what the GDAL driver is supposed to do? I had hoped that I would end up with the HTML/XML parsed to separate fields. Either way I need a solution to extract that information. Any pointers on that? –  marty_c Sep 5 '13 at 13:16
    
@marty_c; I think it is doing what it is designed to do, yes. In this case, the data in the description field just happens to be an HTML table. As for how to parse it out; that's a great question. Perhaps you could reword the question above (or start a new one?) to specifically ask it? –  Darren Cope Sep 5 '13 at 14:09
    

Not the answer you're looking for? Browse other questions tagged or ask your own question.