Skip to content

Conversation

@barisoztas
Copy link
Contributor

@barisoztas barisoztas commented Nov 18, 2025

Due to a known bug with the xarray 2025.10.1 version, Dataset/DataArray coordinates names that are different from the dimension names are not included in the columns when converting a Dataset/DataArray with to_dataframe().

In this case, since summary_geometry was not same as the dimension name (i.e. geometry), summary_geometry column was not included the the df resulting a KeyError while trying to set geometry at;

xvec/xvec/accessor.py

Lines 959 to 961 in a88c521

return df.set_geometry(
geometry, crs=self._obj[geometry].attrs.get("crs", None)
) # type: ignore

@barisoztas barisoztas marked this pull request as draft November 19, 2025 19:00
barisoztas

This comment was marked as outdated.

if geometry not in self._geom_coords_all: # variable geometry
return df.set_geometry(geometry, crs=self._obj.proj.crs)

# coordinate geometry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include a comment here explaining what is happening with a link to the xarray issue? I'd like to see this as a temporary measure until it gets fixed in upstream.

@barisoztas barisoztas marked this pull request as ready for review November 20, 2025 11:04
Copy link
Member

@martinfleis martinfleis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@martinfleis martinfleis merged commit 8cc8ad1 into xarray-contrib:main Nov 20, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants