greenwich/raster.py
def geom_to_array(geom, size, affine):
    """Converts an OGR polygon to a 2D NumPy array.

    Arguments:
    geom -- OGR Geometry
    size -- array size in pixels as a tuple of (width, height)
    affine -- AffineTransform
    """
    driver = ImageDriver('MEM')
    rast = driver.raster(driver.ShortName, size)
    rast.affine = affine
    rast.sref = geom.GetSpatialReference()
    with MemoryLayer.from_records([(1, geom)]) as ml:
        status = gdal.RasterizeLayer(rast.ds, (1,), ml.layer, burn_values=(1,))
    arr = rast.array()
    rast.close()
    return arr
def geom_to_array(geom, size, affine):
    driver = ImageDriver('MEM')
    rast = driver.raster(driver.ShortName, size)
    rast.affine = affine
    rast.sref = geom.GetSpatialReference()
    with MemoryLayer.from_records([(1, geom)]) as ml:
        status = gdal.RasterizeLayer(rast.ds, (1,), ml.layer, burn_values=(1,))
    arr = rast.array()
    rast.close()
    return arr
def geom_to_array ( geom , size , affine ) : driver = ImageDriver ( 'MEM' ) rast = driver . raster ( driver . ShortName , size ) rast . affine = affine rast . sref = geom . GetSpatialReference ( ) with MemoryLayer . from_records ( [ ( 1 , geom ) ] ) as ml : status = gdal . RasterizeLayer ( rast . ds , ( 1 , ) , ml . layer , burn_values = ( 1 , ) ) arr = rast . array ( ) rast . close ( ) return arr
Converts an OGR polygon to a 2D NumPy array.

    Arguments:
    geom -- OGR Geometry
    size -- array size in pixels as a tuple of (width, height)
    affine -- AffineTransform
Converts an OGR polygon to a 2D NumPy array .