  Photometric redshift surveys map the distribution of matter in the Universe
through the positions and shapes of galaxies with poorly resolved measurements
of their radial coordinates. While a tomographic analysis can be used to
recover some of the large-scale radial modes present in the data, this approach
suffers from a number of practical shortcomings, and the criteria to decide on
a particular binning scheme are commonly blind to the ultimate science goals.
We present a method designed to separate and compress the data into a small
number of uncorrelated radial modes, circumventing some of the problems of
standard tomographic analyses. The method is based on the Karhunen-Lo\`{e}ve
transform (KL), and is connected to other 3D data compression bases advocated
in the literature, such as the Fourier-Bessel decomposition. We apply this
method to both weak lensing and galaxy clustering. In the case of galaxy
clustering, we show that the resulting optimal basis is closely associated with
the Fourier-Bessel basis, and that for certain observables, such as the effects
of magnification bias or primordial non-Gaussianity, the bulk of the signal can
be compressed into a small number of modes. In the case of weak lensing we show
that the method is able to compress the vast majority of the signal-to-noise
into a single mode, and that optimal cosmological constraints can be obtained
considering only three uncorrelated KL eigenmodes, considerably simplifying the
analysis with respect to a traditional tomographic approach.
