def extract_contours(array, tile, interval=<NUM_LIT:100>, field='<STR_LIT>', base=<NUM_LIT:0>):
import matplotlib.pyplot as plt<EOL>levels = _get_contour_values(<EOL>array.min(), array.max(), interval=interval, base=base)<EOL>if not levels:<EOL><INDENT>return []<EOL><DEDENT>contours = plt.contour(array, levels)<EOL>index = <NUM_LIT:0><EOL>out_contours = []<EOL>for level in range(len(contours.collections)):<EOL><INDENT>elevation = levels[index]<EOL>index += <NUM_LIT:1><EOL>paths = contours.collections[level].get_paths()<EOL>for path in paths:<EOL><INDENT>out_coords = [<EOL>(<EOL>tile.left + (y * tile.pixel_x_size),<EOL>tile.top - (x * tile.pixel_y_size),<EOL>)<EOL>for x, y in zip(path.vertices[:, <NUM_LIT:1>], path.vertices[:, <NUM_LIT:0>])<EOL>]<EOL>if len(out_coords) >= <NUM_LIT:2>:<EOL><INDENT>out_contours.append(<EOL>dict(<EOL>properties={field: elevation},<EOL>geometry=mapping(LineString(out_coords))<EOL>)<EOL>)<EOL><DEDENT><DEDENT><DEDENT>return out_contours<EOL>
Extract contour lines from an array.

Parameters
----------
array : array
    input elevation data
tile : Tile
    tile covering the array
interval : integer
    elevation value interval when drawing contour lines
field : string
    output field name containing elevation value
base : integer
    elevation base value the intervals are computed from

Returns
-------
contours : iterable
    contours as GeoJSON-like pairs of properties and geometry