diff --git a/dfm_tools/meshkernel_helpers.py b/dfm_tools/meshkernel_helpers.py index e7098b009..f41238464 100644 --- a/dfm_tools/meshkernel_helpers.py +++ b/dfm_tools/meshkernel_helpers.py @@ -423,6 +423,6 @@ def interpolate_bndpli(bnd_gdf,res): if len(bnd_ls_interp_points)==1: #no change if interp results in only one point continue bnd_ls_interp = LineString(bnd_ls_interp_points) - bnd_gdf_interp['geometry'][irow] = bnd_ls_interp + bnd_gdf_interp.loc[irow,'geometry'] = bnd_ls_interp return bnd_gdf_interp diff --git a/tests/test_meshkernel_helpers.py b/tests/test_meshkernel_helpers.py index 719a4b0eb..42c0092bb 100644 --- a/tests/test_meshkernel_helpers.py +++ b/tests/test_meshkernel_helpers.py @@ -316,11 +316,11 @@ def test_generate_bndpli_cutland(): [-68.31, -68.27, 12.10, 12.21, 2, 5]] dxy = 0.02 - + crs = 4326 for params in params_all: lon_min, lon_max, lat_min, lat_max, len_gdf, len_linestr0 = params - mk_object = dfmt.make_basegrid(lon_min, lon_max, lat_min, lat_max, dx=dxy, dy=dxy, crs=4326) + mk_object = dfmt.make_basegrid(lon_min, lon_max, lat_min, lat_max, dx=dxy, dy=dxy, crs=crs) bnd_gdf = dfmt.generate_bndpli_cutland(mk=mk_object, res='h', buffer=0.01) # fig, ax = plt.subplots() @@ -330,3 +330,19 @@ def test_generate_bndpli_cutland(): assert len(bnd_gdf) == len_gdf assert len(bnd_gdf.geometry[0].xy[0]) == len_linestr0 + + +@pytest.mark.unittest +def test_interpolate_bndpli(): + dxy = 0.02 + crs = 4326 + lon_min, lon_max, lat_min, lat_max = -68.55, -68.05, 11.95, 12.4 + + mk_object = dfmt.make_basegrid(lon_min, lon_max, lat_min, lat_max, dx=dxy, dy=dxy, crs=crs) + bnd_gdf = dfmt.generate_bndpli_cutland(mk=mk_object, res='h', buffer=0.01) + bnd_gdf_ref = dfmt.interpolate_bndpli(bnd_gdf, res=0.00511) + + assert len(bnd_gdf) == 1 + assert len(bnd_gdf.geometry[0].xy[0]) == 99 + assert len(bnd_gdf_ref) == 1 + assert len(bnd_gdf_ref.geometry[0].xy[0]) == 377