def rasterize(layer, rast):
driver = ImageDriver('<STR_LIT>')<EOL>r2 = driver.raster(driver.ShortName, rast.size)<EOL>r2.affine = rast.affine<EOL>sref = rast.sref<EOL>if not sref.srid:<EOL><INDENT>sref = SpatialReference(<NUM_LIT>)<EOL><DEDENT>r2.sref = sref<EOL>ml = MemoryLayer(sref, layer.GetGeomType())<EOL>ml.load(layer)<EOL>status = gdal.RasterizeLayer(<EOL>r2.ds, (<NUM_LIT:1>,), ml.layer, options=['<STR_LIT>' % ml.id])<EOL>ml.close()<EOL>return r2<EOL>
Returns a Raster from layer features.

    Arguments:
    layer -- Layer to rasterize
    rast -- Raster with target affine, size, and sref