Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interpolate_points interpolates to top-left corner of pixel, not center #279

Open
emlys opened this issue Nov 3, 2022 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@emlys
Copy link
Member

emlys commented Nov 3, 2022

The wind energy model expects that interpolate_points interpolates values to the center of each pixel.
The coordinates passed to scipy.interpolate.griddata are the upper left coordinates of each pixel:

for offset in offset_list:
grid_y, grid_x = numpy.mgrid[
offset['yoff']:offset['yoff']+offset['win_ysize'],
offset['xoff']:offset['xoff']+offset['win_xsize']]
grid_y = grid_y * geotransform[5] + geotransform[3]
grid_x = grid_x * geotransform[1] + geotransform[0]
# this is to be consistent with GDAL 2.0's change of 'nearest' to
# 'near' for an interpolation scheme that SciPy did not change.
if interpolation_mode == 'near':
interpolation_mode = 'nearest'
raster_out_array = scipy.interpolate.griddata(
point_array, value_array, (grid_y, grid_x), interpolation_mode,
nodata)

@emlys emlys added the bug Something isn't working label Nov 3, 2022
@emlys emlys self-assigned this Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant