raster_stream_buffer.py
def hat_distance_kernel(pixel_radius, kernel_filepath):
    """Create a raster-based 0, 1 kernel path.

    Parameters:
        pixel_radius (int): Radius of the kernel in pixels.
        kernel_filepath (string): The path to the file on disk where this
            kernel should be stored.  If this file exists, it will be
            overwritten.

    Returns:
        None

    """
    kernel_size = int((pixel_radius)*2+1)
    driver = gdal.GetDriverByName('GTiff')
    kernel_dataset = driver.Create(
        kernel_filepath.encode('utf-8'), kernel_size, kernel_size, 1,
        gdal.GDT_Float32, options=[
            'BIGTIFF=IF_SAFER', 'TILED=YES', 'BLOCKXSIZE=256',
            'BLOCKYSIZE=256'])
    # Make some kind of geotransform, it doesn't matter what but
    # will make GIS libraries behave better if it's all defined
    kernel_dataset.SetGeoTransform([0, 1, 0, 0, 0, -1])
    srs = osr.SpatialReference()
    srs.SetWellKnownGeogCS('WGS84')
    kernel_dataset.SetProjection(srs.ExportToWkt())
    kernel_band = kernel_dataset.GetRasterBand(1)
    kernel_band.SetNoDataValue(-9999)
    cols_per_block, rows_per_block = kernel_band.GetBlockSize()
    row_indices, col_indices = numpy.indices(
        (kernel_size, kernel_size), dtype=numpy.float) - pixel_radius

    kernel_index_distances = numpy.hypot(row_indices, col_indices)
    kernel = kernel_index_distances <= pixel_radius
    kernel_band.WriteArray(kernel)

    kernel_band.FlushCache()
    kernel_dataset.FlushCache()
    kernel_band = None
    kernel_dataset = None
Create a raster-based 0, 1 kernel path.

    Parameters:
        pixel_radius (int): Radius of the kernel in pixels.
        kernel_filepath (string): The path to the file on disk where this
            kernel should be stored.  If this file exists, it will be
            overwritten.

    Returns:
        None

    
Create a raster-based 0, 1 kernel path.
Create a raster - based 0 1 kernel path .
def hat_distance_kernel(pixel_radius, kernel_filepath):
    kernel_size = int((pixel_radius)*2+1)
    driver = gdal.GetDriverByName('GTiff')
    kernel_dataset = driver.Create(
        kernel_filepath.encode('utf-8'), kernel_size, kernel_size, 1,
        gdal.GDT_Float32, options=[
            'BIGTIFF=IF_SAFER', 'TILED=YES', 'BLOCKXSIZE=256',
            'BLOCKYSIZE=256'])
    kernel_dataset.SetGeoTransform([0, 1, 0, 0, 0, -1])
    srs = osr.SpatialReference()
    srs.SetWellKnownGeogCS('WGS84')
    kernel_dataset.SetProjection(srs.ExportToWkt())
    kernel_band = kernel_dataset.GetRasterBand(1)
    kernel_band.SetNoDataValue(-9999)
    cols_per_block, rows_per_block = kernel_band.GetBlockSize()
    row_indices, col_indices = numpy.indices(
        (kernel_size, kernel_size), dtype=numpy.float) - pixel_radius
    kernel_index_distances = numpy.hypot(row_indices, col_indices)
    kernel = kernel_index_distances <= pixel_radius
    kernel_band.WriteArray(kernel)
    kernel_band.FlushCache()
    kernel_dataset.FlushCache()
    kernel_band = None
    kernel_dataset = None
def hat_distance_kernel ( pixel_radius , kernel_filepath ) : kernel_size = int ( ( pixel_radius ) * 2 + 1 ) driver = gdal . GetDriverByName ( 'GTiff' ) kernel_dataset = driver . Create ( kernel_filepath . encode ( 'utf-8' ) , kernel_size , kernel_size , 1 , gdal . GDT_Float32 , options = [ 'BIGTIFF=IF_SAFER' , 'TILED=YES' , 'BLOCKXSIZE=256' , 'BLOCKYSIZE=256' ] ) kernel_dataset . SetGeoTransform ( [ 0 , 1 , 0 , 0 , 0 , - 1 ] ) srs = osr . SpatialReference ( ) srs . SetWellKnownGeogCS ( 'WGS84' ) kernel_dataset . SetProjection ( srs . ExportToWkt ( ) ) kernel_band = kernel_dataset . GetRasterBand ( 1 ) kernel_band . SetNoDataValue ( - 9999 ) cols_per_block , rows_per_block = kernel_band . GetBlockSize ( ) row_indices , col_indices = numpy . indices ( ( kernel_size , kernel_size ) , dtype = numpy . float ) - pixel_radius kernel_index_distances = numpy . hypot ( row_indices , col_indices ) kernel = kernel_index_distances <= pixel_radius kernel_band . WriteArray ( kernel ) kernel_band . FlushCache ( ) kernel_dataset . FlushCache ( ) kernel_band = None kernel_dataset = None
Create a raster-based 0, 1 kernel path.
Create a raster - based 0 1 kernel path .
"""Create a raster-based 0, 1 kernel path.

    Parameters:
        pixel_radius (int): Radius of the kernel in pixels.
        kernel_filepath (string): The path to the file on disk where this
            kernel should be stored.  If this file exists, it will be
            overwritten.

    Returns:
        None

    """ # Make some kind of geotransform, it doesn't matter what but # will make GIS libraries behave better if it's all defined
None
pixel_radius
Radius of the kernel in pixels.
Radius of the kernel in pixels .
kernel_filepath
The path to the file on disk where this
kernel should be stored.  If this file exists, it will be
overwritten.
The path to the file on disk where this kernel should be stored . If this file exists it will be overwritten .