This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Windowed multiprocessing wrapper for rasterio

Project Description

Parallel processing wrapper for rasterio

|PyPI| |Build Status| |Coverage Status|


From pypi:

``pip install rio-mucho``

From github (usually for a branch / dev):

``pip install pip install git+ssh://<branch>``



git clone
cd rio-mucho
pip install -e .


.. code:: python

with riomucho.RioMucho([{inputs}], {output}, {run function},
global_args={global arguments},
options={options to write}) as rios:{processes})



An list of file paths to open and read.


What file to write to.


A function to be applied to each window chunk. This should have input
arguments of:

1. A data input, which can be one of:

- A list of numpy arrays of shape (x,y,z), one for each file as
specified in input file list ``mode="simple_read" [default]``
- A numpy array of shape ({*n* input files x *n* band count}, {window
rows}, {window cols}) ``mode=array_read"``
- A list of open sources for reading ``mode="manual_read"``

2. A ``rasterio`` window tuple
3. A ``rasterio`` window index (``ij``)
4. A global arguments object that you can use to pass in global

This should return:

1. An output array of ({count}, {window rows}, {window cols}) shape, and
of the correct data type for writing

.. code:: python

def basic_run({data}, {window}, {ij}, {global args}):
## do something
return {out}

Keyword arguments


A list of ``rasterio`` (window, ij) tuples to operate on.
``[Default = src[0].block_windows()]``

``global_args={global arguments}``

Since this is working in parallel, any other objects / values that you
want to be accessible in the ``run_function``. ``[Default = {}]``

.. code:: python

global_args = {
'divide_value': 2

``options={keyword args}``

The options to pass to the writing output. ``[Default = srcs[0].meta``


.. code:: python

import riomucho, rasterio, numpy

def basic_run(data, window, ij, g_args):
## do something
out = np.array(
[d[0] /= global_args['divide'] for d in data]
return out

# get windows from an input
with'/tmp/test_1.tif') as src:
## grabbing the windows as an example. Default behavior is identical.
windows = [[window, ij] for ij, window in src.block_windows()]
options = src.meta
# since we are only writing to 2 bands

global_args = {
'divide': 2

processes = 4

# run it
with riomucho.RioMucho(['input1.tif','input2.tif'], 'output.tif', basic_run,
options=options) as rm:

Utility functions

\`riomucho.utils.array\_stack([array, array, array,...])

Given a list of ({depth}, {rows}, {cols}) numpy arrays, stack into a
single (l{list length \* each image depth}, {rows}, {cols}) array. This
is useful for handling variation between ``rgb`` inputs of a single
file, or separate files for each.

One RGB file

.. code:: python

files = ['rgb.tif']
open_files = [ for f in files]
rgb = `riomucho.utils.array_stack([ for src in open_files])

Separate RGB files

.. code:: python

files = ['r.tif', 'g.tif', 'b.tif']
open_files = [ for f in files]
rgb = `riomucho.utils.array_stack([ for src in open_files])

.. |PyPI| image::
.. |Build Status| image::
.. |Coverage Status| image::
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
rio-mucho-0.2.2.tar.gz (4.8 kB) Copy SHA256 Checksum SHA256 Source Aug 25, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting