How Do I Create X,y,z Coordinates From Three Arrays, Where X And Y Are Generated With Meshgrid And Z Is Dependent On X?
I am trying to create x,y,z coordinates to generate an elevation dataset. I was able to create x,y,z arrays with meshgrid- where z is a constant value. (This is a follow on from m
Solution 1:
Remove the
for a2, b2, c2 in zip(a1, b1, c1):
part, and rewrite the coords.append to
coords.append(a1, b1, c1)
The error about "needs to be iterable" is because when you iterate over zip(a, b, c), you're getting a tuple of integer, and not a tuple of np.array.
Solution 2:
You have different shape in those two code versions. You can use code below to get information:
print(x_mesh.shape)
print(y_mesh.shape)
print(z_mesh.shape)
# code version one's output
(700, 2000, 1)
(700, 2000, 1)
(700, 2000, 1)
# code version two's output
(4, 4)
(4, 4)
(4, 4)
In order to solve this problem, you can use code below to add one dimension
x_mesh = x_mesh[..., None]
y_mesh = y_mesh[..., None]
z = z[..., None]
Post a Comment for "How Do I Create X,y,z Coordinates From Three Arrays, Where X And Y Are Generated With Meshgrid And Z Is Dependent On X?"