File: test_tools.py

package info (click to toggle)
rasterio 1.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,732 kB
  • sloc: python: 23,119; sh: 947; makefile: 275; xml: 29
file content (23 lines) | stat: -rw-r--r-- 792 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from functools import partial

from rasterio.features import dataset_features
from rasterio import tools


def test_dataset_features_tool(tmpdir, path_rgb_byte_tif):
    """Example tool works"""
    features_file = tmpdir.join("footprint.jsons")

    tools.dataset_features_tool(path_rgb_byte_tif, str(features_file), func_kwargs=dict(bidx=1, as_mask=True))

    assert features_file.read().count("Feature") == 9


def test_dataset_features_partial(tmpdir, path_rgb_byte_tif):
    """JSON sequence tool works with partially evaluated dataset_features"""
    features_file = tmpdir.join("footprint.jsons")
    tool = tools.JSONSequenceTool(partial(dataset_features, bidx=1, as_mask=True))

    tool(path_rgb_byte_tif, str(features_file))

    assert features_file.read().count("Feature") == 9