CachedRasterRecipe

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.AAsyncRaster(<implementation detail>)[source]

Base abstract class defining the common behavior of all rasters that are managed by the Dataset’s scheduler.

Features Defined

  • Has a queue_data, a low level method that can be used to query several arrays at once.

  • Has an iter_data, a higher level wrapper of queue_data.

queue_data(fps, channels=None, dst_nodata=None, interpolation='cv_area', max_queue_size=5, **kwargs)[source]

Read several rectangles of data on several channels from the source raster.

Using queue_data instead of multiple calls to get_data allows more parallelism. The fps parameter should contain a sequence of Footprint that will be mapped to numpy.ndarray. The first ones will be computed with a higher priority than the later ones.

Calling this method sends an asynchronous message to the Dataset’s scheduler with the input parameters and a queue. On the input side of the queue, the scheduler will call the put method with each array requested. On the output side of the queue, the get method should be called to retrieve the requested arrays.

The output queue will be created with a max queue size of max_queue_size, the scheduler will be careful to prepare only the arrays that can fit in the output queue. Thanks to this feature: backpressure can be entirely avoided.

If you wish to cancel your request, loose the reference to the queue and the scheduler will gracefuly cancel the query.

In general you should use the iter_data method instead of the queue_data one, it is much safer to use. However you will need to pass the queue_data method of a raster, to create another raster (a recipe) that depends on the first raster.

see rasters’ get_data documentation, it shares most of the concepts

Parameters

fps: sequence of Footprint

The Footprints at which the raster should be sampled.

channels:

see get_data method

dst_nodata:

see get_data method

interpolation:

see get_data method

max_queue_size: int

Maximum number of arrays to prepare in advance in the underlying queue.

Returns

queue: queue.Queue of ndarray

The arrays are put into the queue in the same order as in the fps parameter.

iter_data(fps, channels=None, dst_nodata=None, interpolation='cv_area', max_queue_size=5, **kwargs)[source]

Read several rectangles of data on several channels from the source raster.

The iter_data method is a higher level wrapper around the queue_data method. It returns a python generator and while waiting for data, it periodically probes the Dataset’s scheduler to reraise an exception if it crashed.

If you wish to cancel your request, loose the reference to the iterable and the scheduler will gracefully cancel the query.

see rasters’ get_data documentation, it shares most of the concepts see queue_data documentation, it is called from within the iter_data method

Parameters

fps: sequence of Footprint

The Footprints at which the raster should be sampled.

channels:

see get_data method

dst_nodata:

see get_data method

interpolation:

see get_data method

max_queue_size: int

Maximum number of arrays to prepare in advance in the underlying queue.

Returns

iterable: iterable of ndarray

The arrays are yielded into the generator in the same order as in the fps parameter.

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

Base abstract class defining the common behavior of all rasters that compute data on the fly through the Dataset’s scheduler.

Features Defined

  • Has a primitives property, a dict that lists the primitive rasters declared at construction.

property primitives

dict of primitive name to Source, deduced from the queue_data_per_primitive provided at construction.

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

Concrete class defining the behavior of a raster computed on the fly and fills a cache to avoid subsequent computations.

>>> help(Dataset.create_cached_raster_recipe)
property cache_tiles

Cache tiles provided or created at construction

property cache_dir

Cache directory path provided at construction