rasterio/tests/test_rio_calc.py
Sean Gillies e49822e585 rio-calc, take 1.
Like this:

  $ rio calc "0.10*{1} + 125" tests/data/shade.tif out.tif

Results in a new hillshade with shade values of 125 instead of 0.
2015-02-07 15:51:43 -07:00

23 lines
548 B
Python

import sys
import logging
from click.testing import CliRunner
import rasterio
from rasterio.rio.calc import calc
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
def test_multiply(tmpdir):
outfile = str(tmpdir.join('out.tif'))
runner = CliRunner()
result = runner.invoke(calc, [
'0.10*{1} + 125', 'tests/data/shade.tif', outfile],
catch_exceptions=False)
assert result.exit_code == 0
with rasterio.open(outfile) as src:
data = src.read()
assert data.min() == 125