You can use reindex:
da.reindex(lat = da.lat[::-1])
One option is to the.sortby method on your xarray dataset (ds):
ds = ds.sortby('lat', ascending=True)
You can use .isel()
on the dataset object to return a new dataset object with the latitudes reversed for all of the data arrays.
ds = ds.isel(lat=slice(None, None, -1))
Note, this can also be done to a specific data array object, but if you assign that data array back to the dataset object, the coordinates will not be reversed because it will follow the coordinates as stored in the original dataset object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.