rasterio/tests/test_warnings.py
Sean Gillies 35a5906f57
Add a rio create command. (#3023)
* Add a rio create command.

Resolves #3021.

* Eliminate deprecated pytest.warns usage

* Add CLI doc for rio create

* Fix punctuation.

* Add bounds option for geotransform, remove duplicate nodata option.

* Warn about duplicate georeferencing
2024-02-08 16:13:30 -07:00

41 lines
1.4 KiB
Python

import rasterio
from rasterio.errors import NodataShadowWarning, NotGeoreferencedWarning
from affine import Affine
import pytest
def gen_rpcs():
with rasterio.open('tests/data/RGB.byte.rpc.vrt') as src:
return src.rpcs
def test_nodata_shadow():
assert str(NodataShadowWarning()) == (
"The dataset's nodata attribute is shadowing "
"the alpha band. All masks will be determined "
"by the nodata attribute")
def test_notgeoref_warning():
with rasterio.MemoryFile() as mem:
with mem.open(driver='GTiff', width=10, height=10, dtype='uint8', count=1) as src:
pass
with pytest.warns(NotGeoreferencedWarning):
with mem.open() as dst:
pass
@pytest.mark.parametrize('transform, gcps, rpcs', [(Affine.identity() * Affine.scale(2.0), None, None),
(None, [rasterio.control.GroundControlPoint(0, 0, 0, 0, 0)], None),
(None, None, gen_rpcs())])
def test_no_notgeoref_warning(transform, gcps, rpcs):
with rasterio.MemoryFile() as mem:
with mem.open(driver='GTiff', width=10, height=10, dtype='uint8', count=1, transform=transform) as src:
if gcps:
src.gcps = (gcps, rasterio.crs.CRS.from_epsg(4326))
if rpcs:
src.rpcs = rpcs
with mem.open() as dst:
pass