(fn)
return [polygon]
Extracts coordinates from a .kml file.
    
    KV WRL 2018

    Arguments:
    -----------
    fn: str
        filepath + filename of the kml file to be read          
                
    Returns:    
    -----------
    polygon: list
        coordinates extracted from the .kml file
Extracts coordinates from a .kml file.
    
    KV WRL 2018
Extracts coordinates from a . kml file . KV WRL 2018
def polygon_from_kml(fn):
    """
    Extracts coordinates from a .kml file.
    
    KV WRL 2018

    Arguments:
    -----------
    fn: str
        filepath + filename of the kml file to be read          
                
    Returns:    
    -----------
    polygon: list
        coordinates extracted from the .kml file
        
    """    
    
    # read .kml file
    with open(fn) as kmlFile:
        doc = kmlFile.read() 
    # parse to find coordinates field
    str1 = '<coordinates>'
    str2 = '</coordinates>'
    subdoc = doc[doc.find(str1)+len(str1):doc.find(str2)]
    coordlist = subdoc.split('\n')
    # read coordinates
    polygon = []
    for i in range(1,len(coordlist)-1):
        polygon.append([float(coordlist[i].split(',')[0]), float(coordlist[i].split(',')[1])])
        
    return [polygon]
def polygon_from_kml ( fn ) : # read .kml file with open ( fn ) as kmlFile : doc = kmlFile . read ( ) # parse to find coordinates field str1 = '<coordinates>' str2 = '</coordinates>' subdoc = doc [ doc . find ( str1 ) + len ( str1 ) : doc . find ( str2 ) ] coordlist = subdoc . split ( '\n' ) # read coordinates polygon = [ ] for i in range ( 1 , len ( coordlist ) - 1 ) : polygon . append ( [ float ( coordlist [ i ] . split ( ',' ) [ 0 ] ) , float ( coordlist [ i ] . split ( ',' ) [ 1 ] ) ] ) return [ polygon ]