1

I try to read a kml file in R. In the past, there was a post (link). I checked stack overflow and found similar posts. By following the examples, I was trying to read a kml file. I could read the kml file using getKMLcoordinates() in the maptool package and extract geo data (i.e., longitude and latitude). I also used the rgdal package in order to see layer names. But, ogrListLayers(dsn = "name.kml") surprisingly returned character(0). My questions are:

  1. Is is possible for kml files not to have layer names?

  2. If there is no layer name, is there still any hope to find the names? Or do you have to simply give up?

P.S. I originally posted this message in stack overflow, but I have not received any suggestions. So I decided to post this message here.

1
  1. As I know, if the kml file is created by google earth, it will has a layer name even if you rename the layer as null in google earth. In that case, the layer name will be "Layer #0" returned by ogrListLayers() function in R.

  2. I think you can open the kml file by text editor and add a name tag. In kml file created by google earth, it usually under the "Folder" tag.

enter image description here

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.