File: test_no_georef.py

package info (click to toggle)
rasterio 1.4.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,760 kB
  • sloc: python: 22,520; makefile: 275; sh: 164; xml: 29
file content (28 lines) | stat: -rw-r--r-- 914 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
24
25
26
27
28
# You should be able to write rasters with no georeferencing, e.g., plain old
# PNGs and JPEGs.

import rasterio


def test_write(tmpdir):
    name = str(tmpdir.join("test.png"))
    with rasterio.open('tests/data/RGB.byte.tif') as src:
        kwargs = src.meta.copy()
        del kwargs['transform']
        del kwargs['crs']
        kwargs['driver'] = 'PNG'
        with rasterio.open(name, 'w', **kwargs) as dst:
            dst.write(src.read())


def test_read_write(tmpdir):
    tif1 = str(tmpdir.join("test.tif"))
    tif2 = str(tmpdir.join("test2.tif"))
    with rasterio.open('tests/data/RGB.byte.tif') as src:
        kwargs = src.meta.copy()
        del kwargs['transform']
        del kwargs['crs']
        with rasterio.open(tif1, 'w', **kwargs) as dst:
            dst.write(src.read())
    with rasterio.open(tif1) as src, rasterio.open(tif2, 'w', **src.meta) as dst:
        dst.write(src.read())