# Filtering don't preserve value in the edge

Hello, I have a DEM (1500x1500 elements. square of 1m size) o and I need to filter the area whose depth is greater than 5 meters. The problem is that selecting only this part of the mesh and filtering the edges of the selected area (depth of 5 m) is also filtered, which is not consistent with the other part of the grid.
What I can do?

Try to rephrase your question adding some more details ? Confess that I have little idea of what you are talking about. `mesh` in this context is a very vague term.

Sorry. I mean an elevation grid. 1500x1500 elements and 1m of dimension element.

Do you speak spanish?

Let’s say I understand it.
But the best is that you show us what you tried and explain what wanted to obtain.

First, thank you very much for your help
I have a dem that goes from heigth -32 to 20 in an extension of 1500x1500 m with 1m square elements.
At depths less than zero I need to smooth the interpolation by means of a filter, for which I can use a mask.
The problem is that after filtering in this way, a new line with height 0 is generated that does not coincide with that of height greater than zero.
What I’m looking for is a way to filter the area, but that the edges are considered in the calculation, but without being altered. In other words, these values ​​are maintained so that it matches the other part of the DEM.
Now in spanish (may be more clear)

Tengo un dem que va desde la cota -32 hasta la 20 en una extensión de 1500x1500 m con elementos cuadrados de 1m.
En las profundidades menores que cero necesito suavisar la interpolación por medio de filtro, para lo cual puedo usar una mascara.
El problema es que luego de filtrar de esa forma se genera una nueva linea con cota 0 que no coincide con la de cotas mayores a cero.
Lo que busco es una forma de filtrar la zona, pero que los bordes sean considerados en el cálculo, pero sin ser alterados. Es decir que se mantengan estos valores para que calce con la otra parte del DEM

That is pretty clear, but it is also not how filtering works - the filter-width is not going to shrink to zero when approaching your zero line. I guess what I would try is to filter the whole thing, then cut off anything above zero, then regrid your data using the original above-zero data, the zero-line as a hard data constraint, and then the smoothed stuff below zero.

Thanks my friend. I will try that and tell you how its work.

This could be done with two `grdclip` operations but we would need a another `grdmath` operator. One that would do `A if A != NaN else B`.
Trivial to implement in Julia/Matlab.