Discard vertex spikes from terrain created via displacement map

Hello together,

currently I try to visualize a terrain from a height map Float32Array. That works so far really good. The terrain is created by extending the existing MeshStandardMaterial with custom uniforms and a DataTexture that receives data from a Float32Array. Some additional shader code adds turbo coloring to the heights and contour lines. I use the PlaneGeometry to create the final mesh.

This is the default visualization with smooth shading.

To remove the dark plane on the edges I simply discard the pixels where the height equals 0.0.

In the picture below there is my actual problem that I would like to solve. I have this huge vertex spikes that I don’t want display. Is there a setting or another geometry that would be more sufficient to display only the terrain or should I adjust my height map texture?

If the terrain is always circular, would using a RingGeometry (instead of PlaneGeometry) remove these spikes?

1 Like

Interesting idea - ill try it out.

Edit: Unfortunately that did not work.

Have thought of preprocessing your heightmaps to average out all samples where the height difference to any of the 8 neighbouring samples exceeds a certain threshold? Beware though that you wouldn’t be able to properly visualize actual vertical cliffs.

1 Like

I’m sorry to hear this.

Anyway, when I try it, I get perfectly cut edge, no spikes at all:


3 Likes

Tried with displacementMap on MeshLambertMaterial, for RingGeometry. :thinking:
Works as expected:

PS. flatShading = true.

3 Likes

Here is my attempt with displacementMap for height and map for color:

3 Likes

It looks like some extra phiSegments need adding

2 Likes

thanks a lot for feedback and response. i’ll try it out and post the results.

I wonder if my height map data is just wrong. I have an array of zeros and then in center there these terrain values. Should I maybe consider using a different value instead of zero?

It still looks like this -

I entered the search terms “SRTM remove spikes” into Google and their “KI overview” returned the following:

To remove spikes from SRTM (Shuttle Radar Topography Mission) data, several techniques can be employed, including filtering, smoothing, and interpolation. These methods aim to eliminate erroneous data points (spikes) while preserving the overall terrain characteristics.

Common Techniques for Spike Removal:

  1. 1. Filtering:
  • Local Maximum/Minimum Filtering: Identify and remove points that exceed a certain threshold compared to their neighbors. This helps eliminate isolated high or low points that are likely spikes.

  • Median Filtering: Replace each data point with the median value of its neighbors. This effectively reduces the impact of outliers while preserving smoother features.

  • 2. Smoothing:

  • Moving Average: Calculate the average elevation within a defined window and replace the center point with this average. This reduces sharp changes in elevation and helps to remove spikes.

  • Gaussian Smoothing: Apply a Gaussian filter to the data. This method uses a weighted average, giving more importance to nearby points, effectively smoothing out the data and reducing spikes.

  • 3. Interpolation:

  • Kriging: A geostatistical method that predicts values at unknown locations based on the spatial correlation of known data points. This can be used to fill in gaps and smooth out irregularities.

  • Spline Interpolation: Fit a smooth curve through the data points and use this curve to estimate elevation values at missing or noisy locations.

  • 4. Specialized Methods:

  • Low-Rank Sparse Method (LRGS): Developed for SRTM data, this method effectively removes mixed errors (including spikes) by associating group sparsity with the low-rank uniqueness of local transformations.

  • Regression Models: For vegetated areas, regression models can be used to correct SRTM elevation biases, potentially reducing the impact of spikes caused by vegetation.

Implementation in Software:

  • SAGA GIS:

Offers tools like Point Filter with “keep maxima (with tolerance)” for spike removal.

  • Landserf:

Provides functions like “flood fill” and “Raster values” to handle spikes and null values.

  • LAStools:

Provides commands like “drop_below” and “drop_above” for outlier removal. However, these functions may not be suitable for all scenarios due to their reliance on absolute values.

Considerations:

  • Data Characteristics:

The type of spikes and the overall terrain characteristics should be considered when choosing a method.

  • Software Capabilities:

Select a software package and tools that offer the desired spike removal methods.

  • Accuracy Requirements:

The desired level of accuracy should guide the choice of methods and parameters.

  • Context:

In some cases, spikes may be real terrain features (e.g., sharp peaks) and should not be removed.

  • Remove noisy spikes from LiDAR data using SAGA GIS and SRTM …

23.07.2012 — * Select Module | Shapes | Points | Point Filter. The Points Filter dialog box appears. * In the Points field, choose t…

dominoc925

  • [image]

  • Removing spikes or dips - Google Groups

These points need to be removed from the point cloud prior to ground filtering, and can’t always be removed by drop_below or drop_

[image]

Google Groups

  • Area S30E148 in Shuttle Radar Topography Mission 1 (SRTM 1) …

Area S30E148 in Shuttle Radar Topography Mission 1 (SRTM 1) containing spikes, speckles and multidirectional stripe errors (unit:

[image]

ResearchGate

  • [image]

  • Alle anzeigen

AI responses may include mistakes. Learn more

Okay - I found the solution and its much easier than I thought.
Its easy enough to set the value to undefined instead to 0 in the Texture to not draw the edges of the plane or the ring geometry.

Drawn with PlaneGeometry.

And this with the RingGeometry.

1 Like

Talking about a poorly specified problem. A “spike” in the context of digital elevation models is something completely different from the problem you solved.

2 Likes

The whole time I was thinking the spikes to be removed were the zigzagged edge (marked below). The vertical lines I’d consider as a nice effect, a kind of surrounding wall.

1 Like

:joy:

post must be at least 10 characters

Indeed. I struggled a lot to find out how to name things.
Thank you a lot for your patience.

3 Likes