3

I have a kml file of roads that I would like to convert into a shapefile using QGIS, I understand that this should be a straightforward task however I am running into the issue of extracting necessary data from each feature in the kml file. Essentially I want all of the information from each kml feature (see google earth screenshot).

enter image description here

I want each of those attributes (FID, AMA_NAME, Shape_Length, etc...) to be displayed in the attribute table in QGIS as separate values. However, when I bring this kml file into QGIS and view the attribute table all of this information is grouped within the description field for each feature (see below QGIS screenshot).

enter image description here

Is there a way to get the information for each feature from the description field into an attribute table or other form that can be queried in QGIS?

  • do you have a link for the kml file? – Mapperz May 9 at 1:00
  • @Mapperz here you go: link – Evan May 9 at 15:20
2

This looks like a typical KML file exported from ArcGIS or similar GIS software, where the KML export tools take all the attribute data and lump them into an HTML blob (including the table, colors and other formatting) in each KML feature's description tag. This is unfortunate, since now you can not easily extract the attributes back out to name/value pairs.

Other KML generation tools do a better job at this by utilizing ExtendedData (with or without a schema defined), which saves the attributes as name/value pairs in each KML feature (Placemark,etc.). That makes it much easier to reverse the process and extract the attributes, as you're attempting to do, plus the attribute data can still create nice balloon content by referencing it via a balloon template containing $[variables]. More info on ExtendedData in the documentation: https://developers.google.com/kml/documentation/extendeddata

So you have a few options, depending on your situation:

  • Get access to the source data, which likely was in a shapefile or other format with the attributes split out.
  • Re-generate the KML with the attributes in ExtendedData (only relevant if you can influence the file's creator).
  • Pull the HTML blob out of each KML feature, and parse it to extract the attribute names & values. There are many ways to do this, and the best technique will depend on which software and scripting tools you have available.

Sorry I don't know of a quick & easy tool to do this, but the question has been asked online numerous times, so you might find more ideas through targeted searching.

2

There is a QGIS Plugin available which "looks at the KML description field to see if there are two column tables with entries, "tag=value" pairs, or "tag: value" pairs that could be expanded into table fields."

KML Tools: https://plugins.qgis.org/plugins/kmltools/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.