I've got some scattered data in the form of (latitude, longitude, someParameterValue). I'm using inverse distance weighting interpolation method to interpolate them in a rectangular grid of pixels. Presently I'm generating the query points for that grid, in python, as given below. Please note that I've converted the (latitude, longitude) coordinates to cartesian (x, y) coordinates :
xr = int(math.ceil(xmax-xmin));
yr = int(math.ceil(ymax-ymin))
xres=yres=1
xr = math.ceil(xr/xres)+1
yr = math.ceil(yr/yres)+1
npts = int(xr * yr)
queryPts = np.zeros(shape=(npts,2))
x1=xmin; y1=ymin
idx=0
while(x1 <= xmax):
while(y1 <= ymax):
#the 2D array of query points is populated here
queryPts[idx] = [x1, y1]
idx += 1
y1 += yres
y1=ymin
x1 += xres
where xmin, ymin, xmax, ymax are the minimum and maximum values of x and y coordinates respectively. Here I feel that populating the query points at intervals of 1 in each of x and y axes is not the right way to go. After calculating the grid of interpolated values, I'm using gdal to turn it into a raster image with the interpolated values scaled to 0-255 for the pixels. A sample image, that I assume to be inappropriate, is shown here
Would like to get suggestions on the following:
- What would be the proper way to generate query points for an interpolation grid i.e. how to set the resolution of the points on x and y axes whose interpolated values that we are going to calculate?
- I can see that the above question is related to the pixel resolution that we want in the final interpolated image. Hence the above question could be asked as: how to generate 2D arrays of (x,y) points (query points?) that correspond to pixels in the rendered image?