I have the problem that inside my nc dataset:
Dimensions are x and y
Coordinates are longitude and latitude:
<xarray.Dataset>
Dimensions: (x: 521, xfit: 6, y: 420)
Coordinates:
longitude (y, x) float32 ...
latitude (y, x) float32 ...
Dimensions without coordinates: x, xfit, y
As you know it is easy to call and value based on index by x and y. for example
if I want to call variable sar_wind which is available, you can use this code
wind_speed_at_x_y_index = ds.sar_wind.isel(x=14,y=45).values.
You will get the speed wind at this index.
Nevertheless, It is important to find the values at given longitude and latitude. I still have no idea how can I call based on longitude and latitude which are the coordinates here.
Is there any way to reshape/reorganize the data to call the values directly using longitude and latitude coordinates?
What I have tried:
I have tried many different options:
option one:
print(ds.sar_wind.where(longitude=14,latitude=15).values)
I got the following error:
TypeError: where() got an unexpected keyword argument 'longitude'
I tried with other functions like sel, I got the same error
The longitude and latitude values are float numbers and not integer.
Like
[4.8334117 4.841021 4.848631 ... 8.818756 8.826535 8.834313 ]
[4.831756 4.8393664 4.8469768 ... 8.817567 8.825347 8.833126 ]
[4.8301 4.8377113 4.8453226 ... 8.816378 8.824158 8.831939 ]