Skip to content

Commit 5a250a2

Browse files
committed
TST: Update GCP tests for GDAL 3.11 GPC_HOMOGRAPHY
1 parent 369dd3b commit 5a250a2

File tree

3 files changed

+66
-6
lines changed

3 files changed

+66
-6
lines changed

test/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
GDAL_GE_36 = version.parse(rasterio.__gdal_version__) >= version.parse("3.6.0")
1919
GDAL_GE_361 = version.parse(rasterio.__gdal_version__) >= version.parse("3.6.1")
2020
GDAL_GE_364 = version.parse(rasterio.__gdal_version__) >= version.parse("3.6.4")
21+
GDAL_GE_3_11 = version.parse(rasterio.__gdal_version__) >= version.parse("3.11.0")
2122

2223

2324
# xarray.testing.assert_equal(input_xarray, compare_xarray)

test/integration/test_integration__io.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from rioxarray._io import build_subdataset_filter
3131
from rioxarray.rioxarray import DEFAULT_GRID_MAP
3232
from test.conftest import (
33+
GDAL_GE_3_11,
3334
GDAL_GE_36,
3435
GDAL_GE_364,
3536
TEST_COMPARE_DATA_DIR,
@@ -976,7 +977,26 @@ def test_rasterio_vrt_with_src_crs():
976977
assert rds.rio.crs == src_crs
977978

978979

979-
def test_rasterio_vrt_gcps(tmp_path):
980+
@pytest.mark.parametrize(
981+
"affine_c_param",
982+
[
983+
pytest.param(
984+
115698.25,
985+
marks=pytest.mark.skipif(
986+
GDAL_GE_3_11,
987+
reason="GDAL 3.10 and earlier used METHOD=GCP_POLYNOMIAL by default",
988+
),
989+
),
990+
pytest.param(
991+
115698.0,
992+
marks=pytest.mark.skipif(
993+
not GDAL_GE_3_11,
994+
reason="GDAL 3.11+ uses METHOD=GCP_HOMOGRAPHY by default if 4 or 5 GCPs (https://github.com/OSGeo/gdal/pull/11949)",
995+
),
996+
),
997+
],
998+
)
999+
def test_rasterio_vrt_gcps(tmp_path, affine_c_param):
9801000
tiffname = tmp_path / "test.tif"
9811001
src_gcps = [
9821002
GroundControlPoint(row=0, col=0, x=156113, y=2818720, z=0),
@@ -1008,7 +1028,7 @@ def test_rasterio_vrt_gcps(tmp_path):
10081028
Affine(
10091029
216.8587081056465,
10101030
0.0,
1011-
115698.25,
1031+
affine_c_param,
10121032
0.0,
10131033
-216.8587081056465,
10141034
2818720.0,

test/integration/test_integration_rioxarray.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
)
3131
from rioxarray.rioxarray import _generate_spatial_coords, _make_coords
3232
from test.conftest import (
33+
GDAL_GE_3_11,
3334
GDAL_GE_361,
3435
TEST_COMPARE_DATA_DIR,
3536
TEST_INPUT_DATA_DIR,
@@ -1170,7 +1171,26 @@ def test_reproject__no_nodata_masked(modis_reproject):
11701171
_assert_xarrays_equal(mds_repr, mdc)
11711172

11721173

1173-
def test_reproject__gcps_kwargs(tmp_path):
1174+
@pytest.mark.parametrize(
1175+
"affine_c_param",
1176+
[
1177+
pytest.param(
1178+
115698.25,
1179+
marks=pytest.mark.skipif(
1180+
GDAL_GE_3_11,
1181+
reason="GDAL 3.10 and earlier used METHOD=GCP_POLYNOMIAL by default",
1182+
),
1183+
),
1184+
pytest.param(
1185+
115698.0,
1186+
marks=pytest.mark.skipif(
1187+
not GDAL_GE_3_11,
1188+
reason="GDAL 3.11+ uses METHOD=GCP_HOMOGRAPHY by default if 4 or 5 GCPs (https://github.com/OSGeo/gdal/pull/11949)",
1189+
),
1190+
),
1191+
],
1192+
)
1193+
def test_reproject__gcps_kwargs(tmp_path, affine_c_param):
11741194
tiffname = tmp_path / "test.tif"
11751195
src_gcps = [
11761196
GroundControlPoint(row=0, col=0, x=156113, y=2818720, z=0),
@@ -1203,7 +1223,7 @@ def test_reproject__gcps_kwargs(tmp_path):
12031223
Affine(
12041224
216.8587081056465,
12051225
0.0,
1206-
115698.25,
1226+
affine_c_param,
12071227
0.0,
12081228
-216.8587081056465,
12091229
2818720.0,
@@ -3222,7 +3242,26 @@ def test_rio_get_gcps(with_z):
32223242
assert gcp.info == gdal_gcp.info
32233243

32243244

3225-
def test_reproject__gcps_file(tmp_path):
3245+
@pytest.mark.parametrize(
3246+
"affine_c_param",
3247+
[
3248+
pytest.param(
3249+
115698.25,
3250+
marks=pytest.mark.skipif(
3251+
GDAL_GE_3_11,
3252+
reason="GDAL 3.10 and earlier used METHOD=GCP_POLYNOMIAL by default",
3253+
),
3254+
),
3255+
pytest.param(
3256+
115698.0,
3257+
marks=pytest.mark.skipif(
3258+
not GDAL_GE_3_11,
3259+
reason="GDAL 3.11+ uses METHOD=GCP_HOMOGRAPHY by default if 4 or 5 GCPs (https://github.com/OSGeo/gdal/pull/11949)",
3260+
),
3261+
),
3262+
],
3263+
)
3264+
def test_reproject__gcps_file(tmp_path, affine_c_param):
32263265
tiffname = tmp_path / "test.tif"
32273266
src_gcps = [
32283267
GroundControlPoint(row=0, col=0, x=156113, y=2818720, z=0),
@@ -3253,7 +3292,7 @@ def test_reproject__gcps_file(tmp_path):
32533292
Affine(
32543293
216.8587081056465,
32553294
0.0,
3256-
115698.25,
3295+
affine_c_param,
32573296
0.0,
32583297
-216.8587081056465,
32593298
2818720.0,

0 commit comments

Comments
 (0)