Let X be quasi-isometric to either the mapping class group equipped with the word metric, or to Teichmuller space equipped with either the Teichmuller metric or the Weil-Petersson metric. We introduce a unified approach to study the coarse geometry of these spaces. We show that the quasi-Lipschitz image in X of a box in R^n is locally near a standard model of a flat in X. As a consequence, we show that, for all these spaces, the geometric rank and the topological rank are equal. The methods are axiomatic and apply to a larger class of metric spaces.