understanding inputs and outputs on scipy.ndimage.map_coordinates
python, scipy
Solution
The output of `map_coordinates` is an interpolation of the value of the original array at the coordinates you've specified.
In your example you input `[[1, 1], [1, 2]]`. This means you want the interpolated value at two locations: the point x=1,y=1 and x=1,y=2. It needs two arrays because each array is the x- and y-coordinates. I.e. there are two coordinates you've asked for: x-coordinates at 1,1 and y-coordinates at 1,2.
The specific example you've chosen is a bit confusing because it looks like `[1, 1]` corresponds to `[x0, y0]` this interpretation is incorrect - it actually corresponds to `[x0, x1]`. This becomes clear with more than 2 points: The general format is `[[x0, x1, x2, ...], [y0, y1, y2, ...]]`.
Your inputs can be as long or short as you like, but the arrays must be the same length since they are coupled.
Problem
I am trying to map a straight line on a set of points in a grid. the data is in a list of x, y, z coordinates. I think map_coordinates is what i want, however i do not undestand the form of the inputs and outputs... any help would be much appreciated. ``` list = [[x1, y1, z1] [x2, y2, z2] ... [xn, yn, zn]] ``` the values I am trying to look up are x and y values. ``` look_up_values= [[x1, y1] [x2, y2] ... [xn, yn]] ``` My question, why does map_coordinates expect a `(2,2)` array and what information is in the output ( a 2 value list). here is a workable example: ``` from scipy.ndimage.interpolation import map_coordinates import numpy as np in_data = np.array([[0.,0.,0.] ,[0.,1.,.2] ,[0.,2.,.4] ,[1.,0.,.2] ,[1.,3.,.5] ,[2.,2.,.7]]) z = map_coordinates(in_data, np.array([[1.,1.],[1.,2.]]), order=1) print z #I do not understand this output... #[1. .2] ``` if i had to guess i would say its interpolating between 2 points on the grid, buy what then would the output mean?