A particle cascade (shower) in a dielectric, for example as initiated by an ultra-high energy cosmic ray, will have an excess of electrons which will emit coherent v{C}erenkov radiation, known as the Askaryan effect. In this work we study the case in which such a particle shower occurs in a medium just below its surface. We show, for the first time, that the radiation transmitted through the surface is independent of the depth of the shower below the surface when observed from far away, apart from trivial absorption effects. As a direct application we use the recent results of the NuMoon project, where a limit on the neutrino flux for energies above $10^{22}$,eV was set using the Westerbork Synthesis Radio Telescope by measuring pulsed radio emission from the Moon, to set a limit on the flux of ultra-high-energy cosmic rays.