Coverage for gws-app / gws / gis / gdalx / _test / raster_test.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-03 10:12 +0100

1"""Tests for GDAL raster data handling.""" 

2 

3 

4import gws 

5import gws.gis.gdalx as gdalx 

6import gws.lib.bounds 

7import gws.lib.crs 

8import gws.lib.image 

9import gws.test.util as u 

10 

11 

12def test_from_and_to_image(): 

13 with u.temp_dir_in_base_dir(True) as d: 

14 img = gws.lib.image.from_size((100, 200), '#ff00ff32') 

15 b = gws.lib.bounds.from_extent((753000, 6640000, 755000, 6641000), gws.lib.crs.WEBMERCATOR) 

16 with gdalx.open_from_image(img, b) as ds: 

17 ds.create_copy(f'{d}/a.png') 

18 

19 with gdalx.open_raster(f'{d}/a.png') as ds: 

20 ds.create_copy(f'{d}/b.tif') 

21 

22 with gdalx.open_raster(f'{d}/a.png') as ds: 

23 img = ds.to_image() 

24 img.to_path(f'{d}/c.jpeg') 

25 

26 # @TODO: verify content and transforms