We work in a first-order setting where structures are spread out over a metric space, with quantification allowed only over bounded subsets. Assuming a doubling property for the metric space, we define a canonical {em core} $mathcal{J}$ associated to such a theory, a locally compact structure that embeds into the type space over any model. The automorphism group of $mathcal{J}$, modulo certain infinitesimal automorphisms, is a locally compact group $mathcal{G}$. The automorphism groups of models of the theory are related with $mathcal{G}$, not in general via a homomorphism, but by a {em quasi-homomorphism}, respecting multiplication up to a certain canonical compact error set. This fundamental structure is applied to describe the nature of approximate subgroups. Specifically we obtain a full classification of (properly) approximate lattices of $SL_n({mathbb{R}})$ or $SL_n({mathbb{Q}}_p)$.