GDALMemRaster

class buzzard.ASource(<implementation detail>)[source]

Base abstract class defining the common behavior of all sources opened in the Dataset.

Features Defined

  • Has a stored spatial reference

  • Has a virtual spatial reference that is influenced by the Dataset’s opening mode

  • Can be closed

property wkt_stored

The spatial reference that can be found in the metadata of a source, in wkt format.

string or None

property proj4_stored

The spatial reference that can be found in the metadata of a source, in proj4 format.

string or None

property wkt_virtual

The spatial reference considered to be written in the metadata of a source, in wkt format.

string or None

property proj4_virtual

The spatial reference considered to be written in the metadata of a source, in proj4 format.

string or None

get_keys()[source]

Get the list of keys under which this source is registered to in the Dataset

property close

Close a source with a call or a context management. The close attribute returns an object that can be both called and used in a with statement

Examples

>>> ds.dem.close()
>>> with ds.dem.close:
        # code...
>>> with ds.acreate_raster('result.tif', fp, float, 1).close as result:
        # code...
>>> with ds.acreate_vector('results.shp', 'linestring').close as roofs:
        # code...
__del__()[source]
class buzzard.AStored(<implementation detail>)[source]

Base abstract class defining the common behavior of all sources that are stored somewhere (like RAM or disk).

Features Defined

  • Has an opening mode

property mode

Open mode, one of {‘r’, ‘w’}

class buzzard.AStoredRaster(<implementation detail>)[source]

Base abstract class defining the common behavior of all rasters that are stored somewhere (like RAM or disk).

Features Defined

  • Has a set_data method that allows to write pixels to storage

set_data(array, fp=None, channels=None, interpolation='cv_area', mask=None, **kwargs)[source]

Write a rectangle of data to the destination raster. Each channel in array is written to one channel in raster in the same order as described by the channels parameter. An optional mask may be provided to only write certain pixels of array.

If fp is not fully within the destination raster, only the overlapping pixels are written. If fp is not on the same grid as the destination raster, remapping is automatically performed using the interpolation algorithm. (It fails if the allow_interpolation parameter is set to False in Dataset (default)). When interpolating:

  • The nodata values are not interpolated, they are correctly spread to the output.

  • At most one pixel may be lost at edges due to interpolation. Provide more context in array to compensate this loss.

  • The mask parameter is also interpolated.

The alpha bands are currently resampled like any other band, this behavior may change in the future.

This method is not thread-safe.

Parameters

array: numpy.ndarray of shape (Y, X) or (Y, X, C)

The values to be written

fp: Footprint of shape (Y, X) or None

If None: write the full source raster If Footprint: write this window to the raster

channels: None or int or slice or sequence of int (see Channels Parameter below)

The channels to be written.

interpolation: one of {‘cv_area’, ‘cv_nearest’, ‘cv_linear’, ‘cv_cubic’, ‘cv_lanczos4’} or None

OpenCV method used if intepolation is necessary

mask: numpy array of shape (Y, X) and dtype bool OR inputs accepted by Footprint.burn_polygons

Channels Parameter

type

value

meaning

NoneType

None (default)

All channels

slice

slice(None), slice(1), slice(0, 2), slice(2, 0, -1)

Those channels

int

0, 1, 2, -1, -2, -3

Channel idx

(int, …)

[0], [1], [2], [-1], [-2], [-3], [0, 1], [-1, 2, 1]

Those channels

Caveat

When using a Raster backed by a driver (like a GDAL driver), the data might be flushed to disk only after the garbage collection of the driver object. To be absolutely sure that the driver cache is flushed to disk, call .close or .deactivate on this Raster.

fill(value, channels=None, **kwargs)[source]

Fill raster with value.

This method is not thread-safe.

Parameters

value: nbr
channels: int or sequence of int (see Channels Parameter below)

The channels to be written

Channels Parameter

type

value

meaning

NoneType

None (default)

All channels

slice

slice(None), slice(1), slice(0, 2), slice(2, 0, -1)

Those channels

int

0, 1, 2, -1, -2, -3

Channel idx

(int, …)

[0], [1], [2], [-1], [-2], [-3], [0, 1], [-1, 2, 1]

Those channels

Caveat

When using a Raster backed by a driver (like a GDAL driver), the data might be flushed to disk only after the garbage collection of the driver object. To be absolutely sure that the driver cache is flushed to disk, call .close or .deactivate on this Raster.

class buzzard.AEmissary(<implementation detail>)[source]

Base abstract class defining the common behavior of all sources that are backed by a driver.

Features Defined

  • Has a driver (like “GTiff” for GDAL’s geotiff driver)

  • Has open_options

  • Has a path (if the driver supports it)

  • Can be deleted (if the driver supports it)

property driver

Get the driver name, such as ‘GTiff’ or ‘GeoJSON’

property open_options

Get the list of options used for opening

property path

Get the file system path of this source, may be the empty string if not applicable

property delete

Delete a source with a call or a context management. May raise an exception if not applicable or if mode = ‘r’ The delete attribute returns an object that can be both called and used in a with statement

Example

>>> ds.dem.delete()
>>> with ds.dem.delete:
        # code...
>>> with ds.acreate_raster('/tmp/tmp.tif', fp, float, 1).delete as tmp:
        # code...
>>> with ds.acreate_vector('/tmp/tmp.shp', 'polygon').delete as tmp:
        # code...
property remove

Delete a source with a call or a context management. May raise an exception if not applicable or if mode = ‘r’ The delete attribute returns an object that can be both called and used in a with statement

Example

>>> ds.dem.delete()
>>> with ds.dem.delete:
        # code...
>>> with ds.acreate_raster('/tmp/tmp.tif', fp, float, 1).delete as tmp:
        # code...
>>> with ds.acreate_vector('/tmp/tmp.shp', 'polygon').delete as tmp:
        # code...
class buzzard.AEmissaryRaster(<implementation detail>)[source]

Base abstract class defining the common behavior of all rasters that are backed by a driver.

Features Defined

None

class buzzard.GDALMemRaster(<implementation detail>)[source]

Concrete class defining the behavior of a GDAL raster using the “MEM” driver.

>>> help(Dataset.create_raster)

Features Defined

None