greenwich/raster.py
def rasterize(layer, rast):
    """Returns a Raster from layer features.

    Arguments:
    layer -- Layer to rasterize
    rast -- Raster with target affine, size, and sref
    """
    driver = ImageDriver('MEM')
    r2 = driver.raster(driver.ShortName, rast.size)
    r2.affine = rast.affine
    sref = rast.sref
    if not sref.srid:
        sref = SpatialReference(4326)
    r2.sref = sref
    ml = MemoryLayer(sref, layer.GetGeomType())
    ml.load(layer)
    status = gdal.RasterizeLayer(
        r2.ds, (1,), ml.layer, options=['ATTRIBUTE=%s' % ml.id])
    ml.close()
    return r2
def rasterize(layer, rast):
    driver = ImageDriver('MEM')
    r2 = driver.raster(driver.ShortName, rast.size)
    r2.affine = rast.affine
    sref = rast.sref
    if not sref.srid:
        sref = SpatialReference(4326)
    r2.sref = sref
    ml = MemoryLayer(sref, layer.GetGeomType())
    ml.load(layer)
    status = gdal.RasterizeLayer(
        r2.ds, (1,), ml.layer, options=['ATTRIBUTE=%s' % ml.id])
    ml.close()
    return r2
def rasterize ( layer , rast ) : driver = ImageDriver ( 'MEM' ) r2 = driver . raster ( driver . ShortName , rast . size ) r2 . affine = rast . affine sref = rast . sref if not sref . srid : sref = SpatialReference ( 4326 ) r2 . sref = sref ml = MemoryLayer ( sref , layer . GetGeomType ( ) ) ml . load ( layer ) status = gdal . RasterizeLayer ( r2 . ds , ( 1 , ) , ml . layer , options = [ 'ATTRIBUTE=%s' % ml . id ] ) ml . close ( ) return r2
Returns a Raster from layer features.

    Arguments:
    layer -- Layer to rasterize
    rast -- Raster with target affine, size, and sref
Returns a Raster from layer features .