@@ -3226,17 +3226,36 @@ def test_bounds__ordered__dataset():
32263226
32273227
32283228@pytest .mark .skipif (not RASTERIO_GE_14 , reason = "Requires rasterio 1.4+" )
3229- def test_non_rectilinear__reproject (open_rasterio ):
3229+ @pytest .mark .parametrize (
3230+ "rename" ,
3231+ [
3232+ None ,
3233+ {"xc" : "longitude" , "yc" : "latitude" },
3234+ {"y" : "lines" , "x" : "pixels" , "xc" : "longitude" , "yc" : "latitude" },
3235+ ],
3236+ )
3237+ def test_non_rectilinear__reproject (rename , open_rasterio ):
32303238 test_file = os .path .join (TEST_INPUT_DATA_DIR , "2d_test.tif" )
32313239 with open_rasterio (test_file ) as xds :
3240+ x_2d_name = "xc"
3241+ y_2d_name = "yc"
3242+ if rename :
3243+ xds = xds .rename (rename )
3244+ x_2d_name = rename ["xc" ]
3245+ y_2d_name = rename ["yc" ]
3246+ if "x" in rename :
3247+ xds .rio .set_spatial_dims (rename ["x" ], rename ["y" ], inplace = True )
3248+ xds .rio .write_coordinate_system (inplace = True )
32323249 xds_1d = xds .rio .reproject (
32333250 "EPSG:4326" ,
32343251 src_geoloc_array = (
3235- xds .coords ["xc" ].values ,
3236- xds .coords ["yc" ].values ,
3252+ xds .coords [x_2d_name ].values ,
3253+ xds .coords [y_2d_name ].values ,
32373254 ),
32383255 georeferencing_convention = "PIXEL_CENTER" ,
32393256 )
3257+ assert x_2d_name not in xds_1d .coords
3258+ assert y_2d_name not in xds_1d .coords
32403259 assert xds_1d .coords ["x" ].shape == (14 ,)
32413260 assert xds_1d .coords ["y" ].shape == (10 ,)
32423261 xds_1d .rio .transform ().almost_equals (
0 commit comments