I am trying to create a surface plot of a mountain in python, of which I have some xyz data. The end result should look something like that. The file is formatted as follows:
616000.0 90500.0 3096.712
616000.0 90525.0 3123.415
616000.0 90550.0 3158.902
616000.0 90575.0 3182.109
616000.0 90600.0 3192.991
616025.0 90500.0 3082.684
616025.0 90525.0 3116.597
616025.0 90550.0 3149.812
616025.0 90575.0 3177.607
616025.0 90600.0 3191.986
and so on. The first column represents the x
coordinate, the middle one the y
coordinate, and z
the altitude that belongs to the xy coordinate.
I read in the data using pandas
and then convert the columns to individual x
, y
, z
NumPy
1D arrays. So far I managed to create a simple 3D scatter plot with a for
loop iterating over each index of each 1D array, but that takes ages and makes the appearance of being quite inefficient.
I've tried to work with scipy.interpolate.griddata
and plt.plot_surface
, but for z
data I always get the error that data should be in a 2D array, but I cannot figure out why or how it should be 2D data. I assume that given I have xyz data, there should be a way to simply create a surface from it. Is there a simple way?