Scipy.interpolate.griddata: cut the z-value and get the area inside

Regarding this: analogy of scipy.interpolate.griddata? I have an additional question: My conclusion is as follows: enter image description here

This is a pyramid with noise (and without land). Is it possible to enter / select a specific z value in scipy.interpolate.griddata so that all points at which are not equal to these z values โ€‹โ€‹are deleted? In my example: for example. I enter a high z-value -> only points with a specific red value (= z-value) should stay alive and show me an empty triangular red triangle. The goal is to get the area inside this noise triangle.

edit: TL; DR: as I just found out, this is the isoline that I'm looking for, and the area inside it.

edit2: So I found out that from this example http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html "grid_z1.T" returns me an array with all z values. In the loop, I could exclude all values โ€‹โ€‹that are not equal to a certain value of z โ†’ I got my isolation. The problem is that it does not delay the iso line , and a grid with some iso values. This is normal, but maybe there are better solutions? Are there any other grid_z.T methods that can fit my needs?

+3
python numpy scipy interpolation
source share
2 answers

In this special case, I could solve it in a simple way: Instead of excluding all values โ€‹โ€‹that are not equal to a specific value of z, I simply excluded all values โ€‹โ€‹that ar above a certain value of z:

if grid_z1.T[i][j] > z0 or math.isnan(grid_z1.T[i][j]): grid_z1.T[i][j] = np.nan 

Since I defined the grid myself, I can easily calculate the area by multiplying the grids by the number of points.

OT: Sorry for the answer that itโ€™s late - I was in the hospital a week.

0
source share

This is best done before converting the data into a grid shape:

 >>> x = [0,4,17] >>> y = [-7,25,116] >>> z = [50,112,47] >> data = np.column_stack([x, y, z]) array([[ 0, -7, 50], [ 4, 25, 112], # <<---------------- Keep this [ 17, 116, 47]]) >>> data = data[data[:,2] == 112] # points with z==112 array([[ 4, 25, 112]]) 

then you can convert the data for plotting using griddata or, for example, the function specified here :

 X, Y, Z = grid(data[0], data[1], data[2]) 
+1
source share

All Articles