def iter_coords(obj):
    """
    Returns all the coordinate tuples from a geometry or feature.

    """
    if isinstance(obj, (tuple, list)):
        coords = obj
    elif 'features' in obj:
        coords = [geom['geometry']['coordinates'] for geom in obj['features']]
    elif 'geometry' in obj:
        coords = obj['geometry']['coordinates']
    else:
        coords = obj.get('coordinates', obj)
    for coord in coords:
        if isinstance(coord, (float, int)):
            yield tuple(coords)
            break
        else:
            for f in iter_coords(coord):
                yield f
def iter_coords ( obj ) : if isinstance ( obj , ( tuple , list ) ) : coords = obj elif 'features' in obj : coords = [ geom [ 'geometry' ] [ 'coordinates' ] for geom in obj [ 'features' ] ] elif 'geometry' in obj : coords = obj [ 'geometry' ] [ 'coordinates' ] else : coords = obj . get ( 'coordinates' , obj ) for coord in coords : if isinstance ( coord , ( float , int ) ) : yield tuple ( coords ) break else : for f in iter_coords ( coord ) : yield f
Returns all the coordinate tuples from a geometry or feature.