4

I have uploaded some addresses to batchgeo along with several columns of data. I've downloaded the kml file which then has the coordiantes. The data structure is the following:

<?xml version="1.0" ?>
<kml xmlns="http://earth.google.com/kml/2.0">
    <Document>
        <Placemark>
            <name>...</name>
            <description>....</description>
            <Point>
                <coordinates>-3.1034345755337,57.144817425039,0</coordinates>
            </Point><address>...</address>
            <styleUrl>#0</styleUrl>
        </Placemark>
    </Document>
</kml>

The "description" tag is a jumbled mess which has the extended data when you click on a point in Google Maps/Earth (url, address etc.). I now want to add some details underneath the current extended data. My current tack is to use pykml, but I can't find an extended data attribute of a pykml object, and I don't see it listed in the documentation. When I click on a placemark in Google earth I want this to appear:

<Description>
item 1
item 2
item 3
</Description>
New data

Could you suggest how to achieve this? Thanks. (btw, pylibkml has this feature but it has been discontinued and I can't find a download link!)

CodeMonkey
  • 22,825
  • 4
  • 35
  • 75
eamon1234
  • 1,555
  • 3
  • 19
  • 38
  • I have the same question, but I'd like to use `CDATA` within the `` tags... any ideas? Here is an example of how it looks like https://developers.google.com/kml/documentation/kml_tut#descriptive_html – otmezger Apr 16 '13 at 08:10
  • @eamon1234 I found a fork of [pylibkml](http://code.google.com/p/pylibkml/wiki/BasicTutorial) in github, just in case you want to use it: https://github.com/GRSEB9S/pylibkml – abu Oct 17 '21 at 10:14

2 Answers2

4

Ok I will play a bit of necromancy here, and leave something which helped me to with similar problem. Here's what worked for me

pm = KML.Placemark(
                KML.name("My extended data point somewhere in sahara!"),
                KML.Point(KML.coordinates("10, 15")),
                KML.ExtendedData( 
                    KML.Data(KML.value('someValueGadzilion'),name='Your value name here')
                ) 
     )
eciu
  • 163
  • 2
  • 2
  • 6
3

I've achieved what you say by using KML.description() method.

Code:

        placemark = KML.Placemark(
            KML.name('poi'),
            KML.description('blabla'),
            KML.LookAt(
                KML.longitude(lat),
                KML.latitude(lon),
                KML.altitude(alt),
                KML.heading('0'),
                KML.tilt(0),
                KML.range('0'),
            ),
            KML.Point(
                KML.coordinates(string)
            )
        )
Albert Vonpupp
  • 4,557
  • 1
  • 17
  • 20
  • do you know how to use with CDATA? thanks. https://developers.google.com/kml/documentation/kml_tut#descriptive_html – otmezger Apr 16 '13 at 08:10