1

I am currently trying to create a 3D surface plot based on some topographic survey data I took. The data consists of a GPS position based in UTM. I then created a mesh, interpolated using the nearest neighbor method, and plotted the surface using plotly. My main problem comes from the fact that my surface plot is very spiky, whereas the scatter plot of just the raw points looks more like what I want. For reference this is topographic data of 4 dunes on a beach.

I think I have narrowed the problem down to the interpolation method, but I just don't know how to fix it so that the graph will be more smooth.

Thanks in advance for any advice/ suggestions.

import numpy as np
import plotly.graph_objects as go
import pandas as pd
from scipy.interpolate import griddata

# Read Data
eBAD = pd.read_csv('EastBeachAllDunes20190202.txt', header = None, delimiter = ',')
eBAD.columns = ["Point #","Northing","Easting","Zed","NaN"]
eBAD = pd.DataFrame(data = eBAD)

# Define Variables
x = np.array(eBAD.Easting)
y = np.array(eBAD.Northing)
z = np.array(eBAD.Zed)

# Creating Mesh
xi = np.linspace(min(x), max(x))
yi = np.linspace(min(y), max(y))
X, Y = np.meshgrid(xi, yi)
Z = griddata((x, y), z, (xi[None,:], yi[:,None]), method='nearest')

# Plot Scatter of Raw GPS Data 
fig = go.Figure(data=[go.Scatter3d(x=x, y=y, z=z,mode='markers')])
#fig.update_layout(scene_aspectmode='data')
fig.update_layout(scene_aspectmode='manual',
                  scene_aspectratio=dict(x = 5, y = 5, z = 0.5))
fig.show()

# Plot Surface Using Mesh
fig2 = go.Figure(data=[go.Surface(x = xi, y = yi, z=Z)])
#fig2.update_layout(scene_aspectmode='data')
fig2.update_layout(scene_aspectmode='manual',
                  scene_aspectratio=dict(x = 5, y = 5, z = 0.5))
fig2.show()

# Plot Surface Using Mesh
fig3 = go.Figure(data=[go.Surface(x = xi, y = yi, z=Z),go.Scatter3d(x=x, y=y, z=z,mode='markers')])
#fig2.update_layout(scene_aspectmode='data')
fig3.update_layout(scene_aspectmode='manual',
                  scene_aspectratio=dict(x = 5, y = 5, z = 0.5))
fig3.show()

Scatter Plot

Surface Plot

Scatter Plot Over Surface Plot. Here you can see that the higher points do not create a good surface visualization.

James Corn
  • 11
  • 1
  • How many points are there in the original x, y, and z arrays? Are you certain that a resolution of 50x50x50 is high enough for your purposes (coming from the default num parameter in linspace)? If you're looking to simply smooth the interpolation, you might change the griddata method to linear or bicubic, but knowing that you are inherently altering your data and thus introducing inaccuracies. – Will.Evo Mar 25 '20 at 19:47
  • I have tried increasing the resolution, and it doesn't seem to help unfortunately. I have also tried the linear and bicubic methods. I am unclear on why a lot of the points do not rest on the surface. It seems as if the interpolation method is skipping data points for whatever reason. – James Corn Mar 25 '20 at 19:59
  • @Will.Evo There are about 2600 points in the data set – James Corn Mar 25 '20 at 20:04
  • Its hard to be of much help without the dataset. In your question when you refer to spiky, do you mean that row of high Z values on the surface? And are you certain those values don't exist in your survey data? There seems to be some sort of high Z section relative to everything else in the scatter plot you posted. – Will.Evo Mar 26 '20 at 17:42

0 Answers0