def coords(obj):
    if isinstance(obj, (tuple, list)):
        coordinates = obj
    elif 'geometry' in obj:
        coordinates = obj['geometry']['coordinates']
    else:
        coordinates = obj.get('coordinates', obj)
    for e in coordinates:
        if isinstance(e, (float, int)):
            yield tuple(coordinates)
            break
        else:
            for f in coords(e):
                yield f
Yield all coordinate coordinate tuples from a geometry or feature.
dataset/ETHPy150Open mapbox/rasterio/rasterio/rio/helpers.py/coords