Absorbing/sponge layers used as boundary conditions for ocean/marine models are examined in the context of the shallow water equations with the aim to minimize the reflection of outgoing waves at the boundary of the computational domain. The optimization of the absorption coefficient is not an issue in continuous models, for the reflection coefficient of outgoing waves can then be made as small as we please by increasing the absorption coefficient. The optimization of the parameters of absorbing layers is therefore a purely discrete problem. A balance must be found between the efficient damping of outgoing waves and the limited spatial resolution with which the resulting spatial gradients must be described. Using a one-dimensional model as a test case, the performances of various spatial distributions of the absorption coefficient are compared. Two shifted hyperbolic distributions of the absorption coefficient are derived from theoretical considerations for a pure propagative and a pure advective problems. These distribution show good performances. Their free parameter has a well-defined interpretation and can therefore be determined on a physical basis. The properties of the two shifted hyperbolas are illustrated using the classical two-dimensional problems of the collapse of a Gaussian-shaped mound of water and of its advection by a mean current. The good behavior of the resulting boundary scheme remains when a full non-linear dynamics is taken into account.