Using a first-principles approach, we investigate the origin of the fine structure in Si 2p photoelectron spectra at the Si(100)2x1 surface and at the Si(100)-SiO2 interface. Calculated and measured shifts show very good agreement for both systems. By using maximally localized Wannier functions, we provide an interpretation in which the effects due to the electronegativity of second nearest neighbor atoms and due to the local strain field are distinguished. Hence, in combination with accurate modeling, photoelectron spectroscopy can provide a direct measure of the strain field at the atomic scale.