Код: Выделить всё
import numpy as np
import pandas as pd
import geopandas as gpd
import xarray as xr
lr_elev = np.random.uniform(low=0,high=4000,size=(11,11))
hr_elev = np.random.uniform(low=0,high=4000,size=(1001,1001))
lr_lats = np.linspace(44.0,45.0,11)
lr_lons = np.linspace(-115.0,-114.0,11)
hr_lats = np.linspace(44.0,45.0,1001)
hr_lons = np.linspace(-115.0,-114.0,1001)
lr_ds = xr.Dataset(
data_vars=dict(
elevation=(['lat','lon'],lr_elev)
),
coords=dict(
lon=('lon',lr_lons),
lat=('lat',lr_lats)
)
)
hr_ds = xr.Dataset(
data_vars=dict(
elevation=(['lat','lon'],hr_elev)
),
coords=dict(
lon=('lon',hr_lons),
lat=('lat',hr_lats)
)
)
print(lr_ds)
print(hr_ds)
Код: Выделить всё
# ### Treat midpoint of HR grid cells as a point -- then find the nearest LR grid cell as if they are stations
nearest_lr_point = lr_ds.sel(lat=hr_ds.lat,lon=hr_ds.lon, method='nearest')
print(nearest_lr_point)
Я не могу легко преобразовать это в кадр данных (поскольку реальный набор данных с высоким разрешением имеет размер около 700 ГБ)
Подробнее здесь: https://stackoverflow.com/questions/798 ... each-of-th
Мобильная версия