Questions tagged [simplekml]

Use for questions about the simplekml Python module used for creating KML files.

simplekml is a Python library for creating Keyhole Markup Language (KML) (or kmz) files. It was designed to hide to the complex details of KML with a simple API that follows the basic structure of KML. If you have a simple understanding of the structure of KML, then simplekml is easy to run with and create usable KML.

Flat learning curve:

Concise, readable and expressive syntax, easy to learn for developers

Hello World

import simplekml
kml = simplekml.Kml()
kml.newpoint(name="Hello", coords=[(18.432314,-33.988862)]) # lon, lat, optional height
kml.save("botanicalgarden.kml")

This is what is generated:

<?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">
    <Document id="1">
        <Placemark id="3">
            <name>Hello</name>
            <Point id="2">
                <coordinates>18.432314,-33.988862,0.0</coordinates>
            </Point>
        </Placemark>
    </Document>
</kml>

Saving a KML document

Simply call kml.save(“pathtomyfile.kml”) passing a path to the file you want to create. Alternatively you can call kml.savekmz(“pathtomyfile.kmz”) to save the KML as a KMZ, or even kml.kml() to get the KML as a string.

Asking Questions:

  • Before asking the question, make sure you have gone through the Getting Started introduction and Tutorials. It covers all the basic functionality of simplekml.

Useful Canonicals:

49 questions
0
votes
1 answer

Python df lat long in for loop

I wanted to change the code into for-loop so that I can change the style for each point. Code below is working fine without for-loop: import simplekml import pandas as pd excel_file = 'sample.xlsx' df=pd.read_excel(excel_file) kml =…
Issac_n
  • 89
  • 1
  • 2
  • 13
0
votes
1 answer

python simplekml change shape of newpoint

I am trying to change the default Yellow Push-PIN place marker to rectangle or pixel. after running code below I still getting default Yellow Push-PIN place marker. import simplekml #from simplekml import Shape,Color kml =…
Issac_n
  • 89
  • 1
  • 2
  • 13
0
votes
1 answer

How can i loop through a list and create/add to a kml using simplekml?

I have a list of coordinates, and i want to create a kml that has all of these linestings based on the list 'coord'. I have it almost working, however, it will only create the linestring for the last coordinate in the list. How can i use append…
ColleenB
  • 135
  • 5
  • 19
0
votes
1 answer

Merging polygons using simplekml module

simplekml module makes multiple polygons instead of a single one. Is there any way to merge the polygons into a single polygon, rather than multiple ones?? import simplekml, pandas as pd tuples=tuple([(72.852333, 29.807333), (73.131333, 29.6055),…
Asad Ullah
  • 43
  • 1
  • 3
  • 7
0
votes
1 answer

Create a kml in python that has both points and lines

I am trying to create a kml file in python (using simplekml) that has both points and lines that connect these points. I also want to make the points into squares instead of the default yellow pushpin. Now i have successfully created kml files that…
ColleenB
  • 135
  • 5
  • 19
0
votes
1 answer

polygon showing up in Google Earth - simpleKML

background - I'm trying to create a circular polygon and add it to a kml using simpleKML. The kml knows that there should be a polygon added, and it has the proper colour, width, and description, but whenever I zoom to the location it leads me to…
0
votes
1 answer

How to save a file on macos desktop using kml in python?

I have just read some of posts on how to save a kml file on macos desktop in Python but i couldn't find the answer.I try to locate the file path but it doesn't work. my code is: import pathlib import simplekml longitude = input("Enter longitude:…
Barish Ahsen
  • 100
  • 1
  • 1
  • 4
0
votes
1 answer

Creating a kml file for google earth - Heat/colour map required

I have csv data containing latitude and longitude. I wish to create a 'heatmap' whereby some placemarks are certain colours based on values corresponding to each lat+long point in the csv. import simplekml import csv kml =…
arsenal88
  • 1,040
  • 2
  • 15
  • 32
0
votes
1 answer

Setting lablestyle in KML

I used the simplekml module for python to create the following KML file
dms_quant
  • 85
  • 1
  • 4
  • 10
0
votes
1 answer

Creating Proper List for SimpleKML library; Python

Any ideas how to create a list of this type? cities = [ ('Aberdeen, Scotland', '5:00 p.m.', 57.15, -2.15), ('Adelaide, Australia', '2:30 a.m.', -34.916667, 138.6), ('Algiers, Algeria', '6:00 p.m.', 36.833333, 3), ('Amsterdam, Netherlands', '6:00…
Kenny Powers
  • 1,254
  • 2
  • 15
  • 25
0
votes
1 answer

How can I turn a massive number of coordinates into a boundary or polygon?

I've got a large number of points that, when plotted individually, make for huge KML files. I would like to create a boundary for these points rather than plotting them individually. I am using python and a package called simplekml.
dubloons
  • 1,136
  • 2
  • 12
  • 25
0
votes
1 answer

Display coordinates from kml

I can't for the life of me figure out how to display coordinates from a simplekml file in Google Earth. I'm using a for loop to get coords from a list as such... for code, label, lat, lon, mm, dte: pnt=kml.newpoint(name=label,coords=[(lon,…
-1
votes
1 answer

Need help creating KML with radio buttons on folders via python simplekml

I will try to explain the problem as best as possible. The code below is used to create a Kml file for Google Earth from a csv file (points recorded by a drone). Each line of the "csv" file includes the time, longitude, latitude and altitude of a…
Toto1515
  • 11
  • 2
-1
votes
1 answer

How to create several polygons with simple kml python?

I am trying to create a program to draw polygons in a kml with simpleKML in python, the idea is to send a list of coordinates to create polygons in different zones, but it is not working for me, could you tell me what I am doing wrong... this is my…
-1
votes
1 answer

Converting CSV to KML for just lat and lon

Below is the code I am using to covert my CSV file to KML into Google Earth Pro; however Google Earth Pro continues to crash when I upload to files. The amount of Lat Lon Coordinates are too great for Google Earth Pro to handle? Am I missing…
JRoth9125
  • 3
  • 3