diff --git a/dfm_tools/hydrolib_helpers.py b/dfm_tools/hydrolib_helpers.py index 8d5c7e495..b1f63e549 100644 --- a/dfm_tools/hydrolib_helpers.py +++ b/dfm_tools/hydrolib_helpers.py @@ -527,6 +527,25 @@ def PolyFile_to_geodataframe_points(polyfile_object:hcdfm.PolyFile, crs:str=None return gdf +def _da_from_gdf_points(gdf_points): + + ncbnd_construct = get_ncbnd_construct() + dimn_point = ncbnd_construct['dimn_point'] + varn_pointx = ncbnd_construct['varn_pointx'] + varn_pointy = ncbnd_construct['varn_pointy'] + varn_pointname = ncbnd_construct['varn_pointname'] + attrs_pointx = ncbnd_construct['attrs_pointx'] + attrs_pointy = ncbnd_construct['attrs_pointy'] + + da_plipoints = xr.Dataset() + da_plipoints[varn_pointx] = xr.DataArray(gdf_points.geometry.x.tolist(), dims=dimn_point).assign_attrs(attrs_pointx) + da_plipoints[varn_pointy] = xr.DataArray(gdf_points.geometry.y.tolist(), dims=dimn_point).assign_attrs(attrs_pointy) + da_plipoints[varn_pointname] = xr.DataArray(gdf_points[varn_pointname].tolist(), dims=dimn_point) + da_plipoints = da_plipoints.set_coords([varn_pointx,varn_pointy,varn_pointname]) + + return da_plipoints + + def PolyFile_to_geodataframe_linestrings(polyfile_object, crs=None): """ empty docstring diff --git a/dfm_tools/interpolate_grid2bnd.py b/dfm_tools/interpolate_grid2bnd.py index 67c4830f7..966146340 100644 --- a/dfm_tools/interpolate_grid2bnd.py +++ b/dfm_tools/interpolate_grid2bnd.py @@ -6,7 +6,6 @@ """ -import os import glob import datetime as dt import numpy as np @@ -22,11 +21,12 @@ from dfm_tools.hydrolib_helpers import (Dataset_to_TimeSeries, Dataset_to_T3D, Dataset_to_Astronomic, - pointlike_to_DataFrame, - PolyFile_to_geodataframe_linestrings, + # pointlike_to_DataFrame, + # PolyFile_to_geodataframe_linestrings, PolyFile_to_geodataframe_points, - gdf_linestrings_to_points, - get_ncbnd_construct) + # gdf_linestrings_to_points, + get_ncbnd_construct, + _da_from_gdf_points) from dfm_tools.errors import OutOfRangeError @@ -372,25 +372,6 @@ def interp_regularnc_to_plipoints(data_xr_reg, file_pli, nPoints=None, load=True return data_interp -def _da_from_gdf_points(gdf_points): - - ncbnd_construct = get_ncbnd_construct() - dimn_point = ncbnd_construct['dimn_point'] - varn_pointx = ncbnd_construct['varn_pointx'] - varn_pointy = ncbnd_construct['varn_pointy'] - varn_pointname = ncbnd_construct['varn_pointname'] - attrs_pointx = ncbnd_construct['attrs_pointx'] - attrs_pointy = ncbnd_construct['attrs_pointy'] - - da_plipoints = xr.Dataset() - da_plipoints[varn_pointx] = xr.DataArray(gdf_points.geometry.x.tolist(), dims=dimn_point).assign_attrs(attrs_pointx) - da_plipoints[varn_pointy] = xr.DataArray(gdf_points.geometry.y.tolist(), dims=dimn_point).assign_attrs(attrs_pointy) - da_plipoints[varn_pointname] = xr.DataArray(gdf_points[varn_pointname].tolist(), dims=dimn_point) - da_plipoints = da_plipoints.set_coords([varn_pointx,varn_pointy,varn_pointname]) - - return da_plipoints - - def interp_regularnc_to_plipointsDataset(data_xr_reg, gdf_points, load=True): ncbnd_construct = get_ncbnd_construct()