Context. The diffuse and translucent molecular clouds traced in absorption along the line of sight to strong background sources have so far been investigated mainly in the spectral domain because of limited angular resolution or small sizes of the background sources. Aims. We aim to resolve and investigate the spatial structure of molecular clouds traced by several molecules detected in absorption along the line of sight to Sgr B2(N). Methods. We have used spectral line data from the EMoCA survey performed with the Atacama Large Millimeter/submillimeter Array (ALMA), taking advantage of its high sensitivity and angular resolution. The velocity structure across the field of view is investigated by automatically fitting synthetic spectra to the detected absorption features, which allows us to decompose them into individual clouds located in the Galactic centre (GC) region and in spiral arms along the line of sight. We compute opacity maps for all detected molecules. We investigated the spatial and kinematical structure of the individual clouds with statistical methods and perform a principal component analysis to search for correlations between the detected molecules. To investigate the nature of the molecular clouds along the line of sight to Sgr B2, we also used archival Mopra data. Results. We identify, on the basis of c-C3H2, 15 main velocity components along the line of sight to Sgr B2(N) and several components associated with the envelope of Sgr B2 itself. The c-C3H2 column densities reveal two categories of clouds. Clouds in Category I (3 kpc arm, 4 kpc arm, and some GC clouds) have smaller c-C3H2 column densities, smaller linewidths, and smaller widths of their column density PDFs than clouds in Category II (Scutum arm, Sgr arm, and other GC clouds). We derive opacity maps for the following molecules: c-C3H2, H13CO+, 13CO, HNC and its isotopologue HN13C, HC15N, CS and its isotopologues C34S and 13CS, SiO, SO, and CH3OH. These maps reveal that most molecules trace relatively homogeneous structures that are more extended than the field of view defined by the background continuum emission (about 15′′, that is 0.08–0.6 pc depending on the distance). SO and SiO show more complex structures with smaller clumps of size ~5–8′′. Our analysis suggests that the driving of the turbulence is mainly solenoidal in the investigated clouds. Conclusions. On the basis of HCO+, we conclude that most line-of-sight clouds towards Sgr B2 are translucent, including all clouds where complex organic molecules were recently detected. We also conclude that CCH and CH are good probes of H2 in both diffuse and translucent clouds, while HCO+ and c-C3H2 in translucent clouds depart from the correlations with H2 found in diffuse clouds.