Read kml file with multiple placemarks in pykml

后端 未结 2 1186
面向向阳花
面向向阳花 2021-01-14 04:54

In pykml, I can read the first placemark in a file using the following code:

 with open(filename) as f:
     pm = parser.parse(f).getroot().Document.Folder
          


        
2条回答
  •  感动是毒
    2021-01-14 05:44

    This works:

    with open(filename) as f:
        doc = parser.parse(f).getroot().Document.Folder
    for pm in doc.iterchildren():
        if hasattr(pm, 'LineString'):
            print pm.LineString.coordinates
    

提交回复
热议问题