I have GPS-telemetry data from animal movement monitoring that records, besides Longitude-Latitude coordinates and date/time, other information (GPS HDOP, elevation and other important stuff).

I can read them in R (using rgdal::readOGR or sf::st_read functions, for example), but they do not recognize this additional information as separate columns. This additional data is read into a column called description that contains all additional information together, in a format that seems like XML. In each row, I have something like (in an example including only HDOP and elevation):

<tr><td>-21.54328, -49.85085, hdop: 1.0, elev: 898.78</td></tr>

The question is: is there an implemented way of reading kml/kmz files with this additional information already organized as separate columns? And, if not, what would be the easiest solution?


1 Answer 1


I don't know much about R, so can't help directly with parsing out the data, but I can tell you that what you're seeing in the KML's description tag is likely some HTML including a Table in the description tag. So if you can get the contents of the description and find a way to parse it as HTML, you might be able to separate out your data attributes into separate fields or columns.

That said, In KML files, there are several ways to save attribute data, and unfortunately many GIS tools do it the way you're seeing, lumping all the data (other than name & geometry) into an HTML blob in the description tag. The better alternative is to use the KML feature's ExtendedData section (with or without a Schema defined), to save actual attribute data (name/value pairs). That allows them to be displayed using a shared balloon template, and more importantly, allows them to easily be parsed back out. If you have any influence over how the KML files are generated, you might see if they be changed to save the attributes in ExtendedData instead. More info on Extended data in the documentation: https://developers.google.com/kml/documentation/extendeddata

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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