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
6
votes
1 answer

Displaying local image in simplekml

I'm trying to use simplekml to put a bunch of geotagged photographs into a KML file (well, a KMZ file actually) to view in Google Earth. I've gotten the locations to display, however when I try to put the image in the "description" so when I click…
Alex S
  • 4,726
  • 7
  • 39
  • 67
5
votes
1 answer

Can I use simplekml shared style and also change the style of individual points?

I've written a script in python that will convert a CSV file to a KML file using the simplekml python package. It's not finished yet as it needs to also scale and color my points based on one of my data values. Right now I'm playing around with this…
R.P.
  • 51
  • 1
  • 5
3
votes
1 answer

Change the tag id attribute in KML (Simplekml)

Is it possible to change the id attribute in a tag in simplekml? import simplekml kml = simplekml.Kml() pnt = kml.newpoint(name='A Point') pnt.coords = [(1.0, 2.0)] kml.save("icon.kml") This will generate the following document
Izaque
  • 51
  • 1
  • 5
3
votes
1 answer

Drawing Great Circles with SimpleKML

I've just been trying to draw some lines on Google Earth using point coordinates and everything works but for a tiny detail. The lines go through the earth and don't follow the surface so they are usually invisible as I've got points all arround the…
3
votes
1 answer

Kml creation error

Recently I've been reading regards the simplekml module that python 2.7 has. So far I've found this to create a point: import simplekml kml = simplekml.Kml() kml.newpoint(name="Kirstenbosch",…
2
votes
1 answer

How do I put a hyperlink into SimpleKML?

The simplekml package gives this intro example: import simplekml kml = simplekml.Kml() kml.newpoint(name="Kirstenbosch", coords=[(18.432314,-33.988862)]) # lon, lat, optional height kml.save("botanicalgarden.kml") I would like to extend it as…
Lars Ericson
  • 1,952
  • 4
  • 32
  • 45
2
votes
1 answer

Check if Folder exists in simplekml - python

This should be extremely easy but I've now been at it an hour with no end in site. I'm using the simplekml module in python and I want to create a folder if one doesn't exists. I can't find anyway to check if a folder exists already without creating…
Jesse Reich
  • 87
  • 1
  • 1
  • 11
2
votes
1 answer

html popup window in simplekml

Say I have an html table:
Company Contact Country
Alfreds Futterkiste Maria Anders Germany
What…
giosans
  • 1,136
  • 1
  • 12
  • 30
2
votes
1 answer

Having problems creating kmls with python

I am creating kml files using python and the simplekml creator. For some reason it creates two kml files and will not create the third. Data seems fine to me. Here is the code: times=open("E:\\Python\Copyofresttable.csv","r") import time import…
1
vote
1 answer

dockered python application can't find installed module simplekml

Hello docker specialists, I start to dockerize my python3 application. The simple Dockerfile contain FROM python:3 WORKDIR /usr/src/app COPY requirements.txt ./ RUN python -m pip install --upgrade pip RUN pip install --no-cache-dir -r…
knigge
  • 31
  • 3
1
vote
0 answers

module 'simplekml' has no attribute 'Kml'

I am using Python3.6.5 and installed with simplekml module 1.3.3, But there is an error message when I running the code below; Error msg>>"kml = simplekml.Kml() AttributeError: module 'simplekml' has no attribute 'Kml'" I am using sample code from…
Issac_n
  • 89
  • 1
  • 2
  • 13
1
vote
1 answer

How to create a .kml file from a dataframe?

I need to create a .kml file from a dataframe with more than 800 districts. This is what I have done so far: 1) Read a .csv file (FIG 1) using PANDAS 2) Creat a new dataframe by choosing only the first 3 columns (longitude, latitude, altitude) 3)…
Aizzaac
  • 3,146
  • 8
  • 29
  • 61
1
vote
1 answer

error while installing simplekml for python3

I wanted to install simplekml for python3. So I tried to install simplekml with the sudo python3 -m pip install simplekml command. But I am getting an error: Collecting simplekml Downloading…
Vikas Bansal
  • 2,184
  • 2
  • 15
  • 18
1
vote
1 answer

Resize or show a 2+ GB KMZ file

I'm using SimpleKML to create a list of ~600 geotagged pictures (where each pin has an image as the description. So I click one of the pins on the map and it shows the picture I took at that coordinate). The KMZ file is roughly 1GB and doesn't seem…
BruceWayne
  • 22,923
  • 15
  • 65
  • 110
1
vote
1 answer

Creating a KML linestring from a CSV with Python and simplekml

I've got a bunch of CSV files containing, amongst other fields, lat and long. Each row is a point on a journey. I'm trying to create a KML that shows the journey as a linestring, but can't quite figure out how to get multiple coords into the…
Ben H
  • 13
  • 1
  • 5
1
2 3 4