Using Python with a set of not regular point X,Y,Z in order to create a regular grid where each pixel is the minimum value of the point
Question: I have a set of not-regular points with X,Y and Z value. I wish to create a
regular square grid (to export in `TIFF` format or `ASCII` format) with a
resolution of 0.5 x 0.5 and extension equal to the boundery box of my data-set
`[X_Min,Y_Min],[X_Max,Y_Min],[X_Max,Y_Max],[X_Min,Y_Max],[X_Min,Y_Min]`

The value of each pixel, where the points are present, need to be the low
value of the points in the pixel.

Sorry if i cannot post any Python code.

Thanks in advance for all Help, suggestions, and link where to solve this
problem


Answer: I assume your points are available in an array like this:

    
    
    points = [(x1,y1,z1), (x2,y2,z2), ...]  
    

To extract the x and y values you can use the zip trick:

    
    
    points_zipped = zip(*points)  
    xvals = points_zipped[0]  
    yvals = points_zipped[1]  
    

Getting the bounding box is then straightforward:

    
    
    xmin, ymin = min(xvals), min(yvals)
    xmax, ymax = max(xvals), max(yvals)
    

To get the minimum points I couldn't come up with something more inspiring
than using defaultdicts from the collections module:

    
    
    from collections import defaultdict
    minpoints = defaultdict(lambda: defaultdict(lambda : 0.))  # 0. or another suitable min value  
    for p in points:  
        minpoints[p[0]][p[1]] = min(p[2], minpoints[p[0]][p[1]])  
    

From there one you could use scipy interpolation. There is a dedicated recipe
for 2d-interpolation of irregularly spaced data:
<http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data>

