diff --git a/xugrid/core/dataarray_accessor.py b/xugrid/core/dataarray_accessor.py index fdeee6b2c..b1ff6d0a6 100644 --- a/xugrid/core/dataarray_accessor.py +++ b/xugrid/core/dataarray_accessor.py @@ -422,7 +422,7 @@ def to_geodataframe( else: ds = self.obj.to_dataset() - variables = [varname for varname, var in ds.variables.items() if dim in var.dims] + variables = [var for var in ds.data_vars if dim in ds[var].dims] # TODO deal with time-dependent data, etc. # Basically requires checking which variables are static, which aren't. # For non-static, requires repeating all geometries. diff --git a/xugrid/core/dataset_accessor.py b/xugrid/core/dataset_accessor.py index 0d783c4d1..3a367f5ab 100644 --- a/xugrid/core/dataset_accessor.py +++ b/xugrid/core/dataset_accessor.py @@ -546,7 +546,7 @@ def to_geodataframe(self, dim_order=None) -> "geopandas.GeoDataFrame": # type: else: raise ValueError("invalid topology dimension on grid") - variables = [varname for varname, var in ds.variables.items() if dim in var.dims] + variables = [var for var in ds.data_vars if dim in ds[var].dims] if variables: data = ds[variables].to_dataframe(dim_order=dim_order) else: