I have a code as below. So basically i have predefined a grid, and i make a loop every single small grid to this larger predefined grid. But the code stuck at the reindex part.it just using too much memory and it crushed.Is there other way i can snap the small grid to a larger grid?
latitudes=np.linspace(20.0000,50.0000,100001)
longitudes=np.linspace(-130.0000,-100.0000,100001)
AREASCORE=np.full((100001,100001),255,dtype=np.uint8)
AREAFUEL=np.full((100001,100001),255,dtype=np.uint8)
datasets_WFHS= xr.DataArray(AREASCORE,name='AREASCORE',dims='latitude','longitude'],coords={'latitude':latitudes,'longitude':longitudes})
print ("created empty array")
for d in glob.glob(r'Z:\travelers\shp\test\*WFHS.nc'):
d=xr.open_dataset(d)
d=d.reindex({'latitude': latitudes, 'longitude': longitudes}, method='nearest', tolerance=0.0001)
print ('done reindex')
d=d.fillna(255).astype(np.uint8)
print ("done fillna")
datasets_WFHS = xr.where(d==255, datasets_WFHS['AREASCORE'], d['AREASCORE'])
print ("done np where")