[gdal-dev] GDAL Interpolation Help

Even Rouault even.rouault at spatialys.com
Wed Sep 27 11:06:52 PDT 2023


Bill,

here you upsample from a 3x3 to a 5x5 array. Consequently each target 
pixel averages 5/3 x 5/3 contributing source pixels , not 2 x 2.  This 
way the total sum of the values of the target array is preserved 
compared to to the sum of the values of the source array, if you 
multiply the sum by 3/5 * 3/5.

To get what you expect you should work with even-sized arrays

Even

Le 27/09/2023 à 19:44, Bill Myers via gdal-dev a écrit :
> Hi,
> I am new to working with GDAL. We are trying to spatially interpolate 
> Numerical Weather Prediction (NWP) model data to an arbitrary 
> location, i.e. lat/lon. We have been using gdal_translate but have 
> been getting unexpected results.
> We have used the resampling method called "average". In this toy 
> example, we are trying to resample to a grid with twice the density of 
> the input data set. As can be seen in the image in the link below, the 
> values at the points that match the input points agree with the input 
> values. That's good. However, the interpolated values do not match our 
> expectations. We would expect the interpolated value at the midpoint 
> (directly between two input points) to be the average of those two 
> input points. As can be seen, this is not the case.
> Can someone please help us understand what we might be doing 
> incorrectly? Also, does GDAL have the functionality that we are 
> looking for?
> Thanks for your help.
> -b
> https://pasteboard.co/uumLD4JtNmp3.png
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230927/a956d21c/attachment.htm>


More information about the gdal-dev mailing list