Hard x-ray absorption spectroscopy is combined with scanning microtomography to reconstruct full near edge spectra of an elemental species at each location on an arbitrary virtual section through a sample. These spectra reveal the local concentrations of different chemical compounds of the absorbing element inside the sample and give insight into the oxidation state, the local atomic structure, and the local projected free density of states. The method is implemented by combining a quick scanning monochromator and data acquisition system with a scanning microprobe setup based on refractive x-ray lenses. The full XANES spectra reconstructed at each point of the tomographic slice allow to detect slight variations in concentrations of chemical compounds, such as metallic and monovalent copper. The method is applied to the analysis of a heterogeneous catalyst.