0

I have a dataset (ds) loaded from a netcdf file in xarray that looks like this:

enter image description here

Where the coordinates (lon, lat) and the data variable (tasmax) are tied to the region dimension. Instead of region, I'd like the dimensions to be lat, lon, time. When I try to remove the region dimension using ds.drop_dim('region') I end up with this:

enter image description here

Which makes it so anything tied to region is gone. How can I reset the dimensions on this dataset so that they are based on lat, lon, and time?

pbreach
  • 16,049
  • 27
  • 82
  • 120
  • 2
    you can't just drop a coordinate of the array. think more about the shape of the data. right now you have 2-dimensional data, indexed by region and time. how do you want the data to be shaped? what is it you are trying to do with the tasmax data? how is your lat/lon data structured (are these "region" IDs on a regular grid or are they actually regions like countries or something)? we need to know more about what the end goal is before we can help. – Michael Delgado Nov 29 '21 at 22:10
  • also [please do not upload images of code/errors when asking a question.](//meta.stackoverflow.com/q/285551). `print(ds)` provides an easy way of creating a string representation of a dataset you can post as code here. better yet, give us an [MRE](/help/minimal-reproducible-example). – Michael Delgado Nov 30 '21 at 01:01
  • This might be a duplicate of, or at least related to [this question](https://stackoverflow.com/questions/67869707/change-dimensions-from-point-coordinate-to-lat-lon-in-xarray-dataset). – astoeriko Dec 13 '21 at 13:59

0 Answers0