Import Simple Data from KML Files
See original GitHub issueHello, this is maybe also a question related to fiona but I will start here. I have a KML file (formerly a shape file with attribute columns) and want to load this KML with GeoPandas. So far so good, however, when returning the geodataframe, the attribute columns that are marked as “Simple Data” in the KML file are missing. Below, I posted a snipped of the KML file, how I load it and what the gdf looks like and what I want it to look like. The KML contains one folder. A google search was not sucessful until now.
Thanks for the help!
KML file:
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="root_doc">
<Schema name="interfaces1" id="interfaces1">
<SimpleField name="id" type="float"></SimpleField>
<SimpleField name="formation" type="string"></SimpleField>
</Schema>
<Folder><name>interfaces1</name>
<Placemark>
<ExtendedData><SchemaData schemaUrl="#interfaces1">
<SimpleData name="formation">Ton</SimpleData>
</SchemaData></ExtendedData>
<Point><coordinates>19.1501280458077,293.313485355882</coordinates></Point>
</Placemark>
..........
</Folder>
</Document></kml>
import fiona
import geopandas as gpd
gpd.io.file.fiona.drvsupport.supported_drivers['KML'] = 'rw'
# empty GeoDataFrame
gdf = gpd.GeoDataFrame()
# iterate over layers
for layer in fiona.listlayers('../../gemgis/data/Test1/KML/interfaces1.kml'):
s = gpd.read_file(
'../../gemgis/data/Test1/KML/interfaces1.kml', driver='KML', layer=layer)
gdf = gdf.append(s, ignore_index=True)
gdf.head()
What I get:
What I want:
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Import KML map data into Google Earth - Android
Import KML map data into Google Earth · On your Android phone or tablet, open the Google Earth app Google Earth . ·...
Read more >KML Tutorial | Keyhole Markup Language - Google Developers
KML is a file format used to display geographic data in an Earth browser such as Google Earth. KML uses a tag-based structure...
Read more >Import your KML map data into Google Earth Web - YouTube
In this video, we will see, How to Import your KML map data into Google Earth Web. Google Earth is a GIS Application...
Read more >Importing KMZ and KML Files for Property Research - YouTube
As you can see - this subscription database imports data to Google Earth from thousands of counties across the U.S. Most notably, ...
Read more >KML files, import and export them with DeltaTracking tools and ...
Import your KML files into DeltaTracking in a simple way, you will not lose your data when changing software ... DeltaTracking allows the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As a workaround, I was able to do this to extract simpledata tags
@andhuang-CLGX solution worked for me on a simple single layer point .kml
It also works on @AlexanderJuestel kml snippet showing “formation” as an attribute field.
Not to say this is a solved issue, but some version of the base case lets you get by. Maybe the multi layer kml is the sticking point as others have mentioned.
EDIT: Note that my KML was also written from geopandas.
System info below (conda installed yesterday)