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:
-
Is is possible for kml files not to have layer names?
-
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.
Best Answer
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.
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.