I have this next code to select the cell position at a given condition. This is from a raster. As you'll see I'm using NumPy and Pandas for this:
f = np.column_stack(np.where(demData>0))
When I print f I get something like this:
print(f)
[[ 0 89]
[ 0 90]
[ 0 91]
[ 1 90]
[ 1 91]
[ 1 92]
[ 1 93]
[ 2 92]
[ 2 93]]
Now with this previous result, what I'd like to obtain is the data value at that cell position. For example:
df = pd.DataFrame(demDataStage)
df.at[1,93]
And, the result:
618.965
I have in mind something like this next code but I only get a single value (the last one corresponding to the last cell in f) but not an array. The result B is a NumPy array but a single number is showing:
row = f[:,0]
col = f[:,1]
for i in row:
for c in col:
B = df.at[i,c]
print(B)
720.123
As you can see it's not a list or array that returns the cell's data value from the raster at each row,col cell position. I have more that 200 columns and rows so it's easier with something similar to what I showed above but I haven't found the way yet. Any suggestion is very appreciated, thanks!