diff --git a/xarray/core/variable.py b/xarray/core/variable.py index 9271d0c4dbd..7c84f6adb49 100644 --- a/xarray/core/variable.py +++ b/xarray/core/variable.py @@ -161,12 +161,14 @@ def as_variable(obj, name=None) -> Variable | IndexVariable: if name is not None and name in obj.dims: # convert the Variable into an Index if obj.ndim != 1: - raise MissingDimensionsError( + warnings.warn( f"{name!r} has more than 1-dimension and the same name as one of its " - f"dimensions {obj.dims!r}. xarray disallows such variables because they " - "conflict with the coordinates used to label dimensions." + f"dimensions {obj.dims!r}. Xarray will not automatically" + "create an Index object that would allow label-based selection.", + RuntimeWarning, ) - obj = obj.to_index_variable() + else: + obj = obj.to_index_variable() return obj