geowombat.apply(infile, outfile, block_func, args=None, count=1, scheduler='processes', gdal_cache=512, n_jobs=4, overwrite=False, tags=None, **kwargs)[source]#

Applies a function and writes results to file.

  • infile (str) – The input file to process.

  • outfile (str) – The output file.

  • block_func (func) – The user function to apply to each block. The function should always return the window, the data, and at least one argument. The block data inside the function will be a 2d array if the input image has 1 band, otherwise a 3d array.

  • args (Optional[tuple]) – Additional arguments to pass to block_func.

  • count (Optional[int]) – The band count for the output file.

  • scheduler (Optional[str]) – The concurrent.futures scheduler to use. Choices are [‘threads’, ‘processes’].

  • gdal_cache (Optional[int]) – The GDAL cache size (in MB).

  • n_jobs (Optional[int]) – The number of blocks to process in parallel.

  • overwrite (Optional[bool]) – Whether to overwrite an existing output file.

  • tags (Optional[dict]) – Image tags to write to file.

  • kwargs (Optional[dict]) – Additional keyword arguments to pass to


None, writes to outfile


>>> import geowombat as gw
>>> # Here is a function with no arguments
>>> def my_func0(w, block, arg):
>>>     return w, block
>>> gw.apply('input.tif',
>>>          'output.tif',
>>>           my_func0,
>>>           n_jobs=8)
>>> # Here is a function with 1 argument
>>> def my_func1(w, block, arg):
>>>     return w, block * arg
>>> gw.apply('input.tif',
>>>          'output.tif',
>>>           my_func1,
>>>           args=(10.0,),
>>>           n_jobs=8)