## get familiar with image resampling

### Quang Quac (view profile)

on 13 Aug 2018
Latest activity Commented on by Rik

### Rik (view profile)

on 14 Aug 2018
I have 2 images:
- DEM (Digital Elevation Model): spatial resolution 40x40m, represents of an area between (284500E, 2800260N) and (309180E, 2758620N). link: https://drive.google.com/file/d/1oiMA-jatzacCxLhOopi2F1XKaJtOLGTp/view?usp=sharing
- TPE: spatial resolution 10x10m, upper left corner coordinate is (284511.25E, 2800238.75N)). link: https://drive.google.com/file/d/1i-T0mgeaR481DyWYzJ86mZOtvzk2sHHh/view?usp=sharing
I have 4 requirements following:
1. Covers the intersected area of DEM.tif and TPE.jpg
2. With a spatial resolution of 20 meter (i.e. each pixel represents 20m by 20m)
3. The first three channels of the image have the Red, Green and Blue values obtained from TPE.jpg
4. The fourth channel stores the elevation calculated from DEM.tif
For step 3 and 4, I want to implement both "Nearest Neighbor" and "Bi-Linear" interpolation.
Anybody can help me answer and write code.
THANKS!

Rik

### Rik (view profile)

on 13 Aug 2018
Maybe griddedinterpolant would be a good choice to try here.
Quang Quac

### Quang Quac (view profile)

on 14 Aug 2018
I already read the link you send but I still not understand something. Can you explain to me?
Rik

### Rik (view profile)

on 14 Aug 2018
What is it specifically you don't understand?
An image can be thought of as a function x and y, that is essentially the underlying assumption when you resample an image. You happen to have the coordinates of both images you're trying to match, so that means you can use those to have an explicit interpolation using those coordinates. Functions like griddedinterpolant do exactly that.