The spectrum of a Gelfand pair of the form (K proportional to N, K), where N is a nilpotent group, can be embedded in a Euclidean space R-d. The identification of the spherical transforms of K-invariant Schwartz functions on N with the restrictions to the spectrum of Schwartz functions on R-d has been proved already when N is a Heisenberg group and in the case where N = N-3,N-2 is the free two-step nilpotent Lie group with three generators, with K = SO3 (Astengo et al. in J Funct Anal 251:772-791, 2007; Astengo et al. in J Funct Anal 256:1565-1587, 2009; Fischer and Ricci in Ann Inst Fourier Gren 59:2143-2168, 2009). We prove that the same identification holds for all pairs in which the K-orbits in the centre of N are spheres. In the appendix, we produce bases of K-invariant polynomials on the Lie algebra n of N for all Gelfand pairs (K proportional to N, K) in Vinberg's list (Vinberg in Trans Moscow Math Soc 64:47-80, 2003; Yakimova in Transform Groups 11:305-335, 2006).