Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5850637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:10:07+00:00 2026-05-22T13:10:07+00:00

I’m using PyKml module in order to form kml inside my Python script. I

  • 0

I’m using PyKml module in order to form kml inside my Python script. I want to display path which consists of array of coordinates and also display all points as placemarks. Currently, I’m trying (without success) to do it following way

 doc = K.kml(
        K.Document(
            K.Placemark(
                 K.Point(
                     K.name("pl1"),
                    K.coordinates("52.4858, 25.9218, 1051.05105105")
                ) 
            ),
            K.Placemark(
                K.name("path1"),
                K.LineStyle(
                    K.color(0x7f00ffff),
                    K.width(10)
                ),
                K.LineString(
                    K.coordinates(
                        coord_str
                    )
                )
            )
        )
    )

Path looks OK, but when I start adding Placemarks, Google Maps displays only first one. What should I use to display all Placemarks on my path?
Do I need some sort of metaprogramming(i.e. add placemarks in object definition automatically)? Or perhaps something else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T13:10:07+00:00Added an answer on May 22, 2026 at 1:10 pm

    This should let you iterate over the objects and associate each point with the lines it terminates:

    from pykml.factory import KML_ElementMaker as K
    from lxml import etree
    
    #line_points here comes from a geojson object
    data = json.loads(open('tib.json').read())
    line_points = data['features'][0]['geometry']['coordinates']
    
    _doc = K.kml()
    
    doc = etree.SubElement(_doc, 'Document')
    
    for i, item in enumerate(line_points):
        doc.append(K.Placemark(
            K.name('pl'+str(i+1)),
            K.Point(
                K.coordinates(
                    str(item).strip('[]').replace(' ', '')
                    )
            )
        )
    )
    
    doc.append(K.Placemark(
        K.name('path'),
        K.LineStyle(
            K.color('#00FFFF'),
            K.width(10)
        ),
        K.LineString(
            K.coordinates(
                ' '.join([str(item).strip('[]').replace(' ', '') for item in line_points])
            )
        )
    ))
    
    s = etree.tostring(_doc)
    
    print s
    

    where line_points is a list of lists like this, with the coordinates:

    [[-134.15611799999999, 34.783318000000001, 0],
     [-134.713527, 34.435267000000003, 0],
     [-133.726201, 36.646867, 0],
     [-132.383655, 35.598272999999999, 0],
     [-132.48034200000001, 36.876308999999999, 0],
     [-131.489846, 36.565426000000002, 0],...
    

    Here (http://sfgeo.org/data/contrib/tiburon.html) is an example of output, jsfiddle of it here: http://jsfiddle.net/bvmou/aTkpN/7/ but there is a problem with the api key when viewed publicly, try on your local machine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
I have a text area in my form which accepts all possible characters from
i want to parse a xhtml file and display in UITableView. what is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.