Viscoacoustic imaging in anisotropic media is achieved by tomographic estimation of the earth attenuation (Q model), and prestack wave equation migration. The proposed Q tomography algorithm uses spectral ratios computed on surface seismic data as the input. An integral tomographic equation relates the Q model with the measured spectral ratios. The tomography numerical implementation results in a linear inversion scheme that we solve by conjugate gradient methods with 3D regularization. The output Q model is combined with VTI or TTI anisotropic models to perform model-driven attenuation and anisotropy compensation during imaging. To that effect we use a viscoacoustic anisotropic Fourier finite differences one-way wave equation migration. Results from a synthetic example and a VTI field dataset from the North Sea demonstrate the accuracy of our tomographic estimation of Q, and the effectiveness of the viscoacoustic wave equation migration for attenuation compensation.