From 9be4f3e5ec34ac8829cb98820e4504a8beba2092 Mon Sep 17 00:00:00 2001 From: Matthew Iannucci Date: Wed, 27 Nov 2024 10:05:27 -0500 Subject: [PATCH] Fix custom dim selection for string fields --- xpublish_wms/wms/get_map.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xpublish_wms/wms/get_map.py b/xpublish_wms/wms/get_map.py index ac2bcd7..88685eb 100644 --- a/xpublish_wms/wms/get_map.py +++ b/xpublish_wms/wms/get_map.py @@ -242,13 +242,16 @@ def select_custom_dim(self, da: xr.DataArray) -> xr.DataArray: for dim, value in self.dim_selectors.items(): if dim in da.coords: dtype = da[dim].dtype + method=None if "timedelta" in str(dtype): value = pd.to_timedelta(value) elif np.issubdtype(dtype, np.integer): value = int(value) + method = "nearest" elif np.issubdtype(dtype, np.floating): value = float(value) - da = da.sel({dim: value}, method="nearest") + method = "nearest" + da = da.sel({dim: value}, method=method) # Squeeze single value dimensions da = da.squeeze()