There are two types of cities in America. In some of them, the people moving in are better educated and make more money than the people moving out. In others, the opposite is true.

In the former category, we have, of course, San Francisco, where over the past 12 years the median in-migrant has earned $12,640 a year more than the median out-migrant did before he or she left. New York, Los Angeles, and Miami are also metro areas where new arrivals make, at the median, more than $5,000 more than their outgoing counterparts. There is something intuitive about this: People are liable to move away when things aren’t going well, and arrive because they’ve gotten a great job.

But it’s paired with a number of other trends that together indicate a widespread sorting occurring between metro areas where housing is expensive and wages are high and ones where they are not. San Francisco, New York City, Los Angeles, San Diego, Washington, D.C., Seattle, and Chicago are the cities in which in-migrants are the most likely to be more highly educated than people leaving town. New residents in these cities also tend to be younger. Their households have more earners (roommates, potentially, or working partners) and are more likely to rent than own.

The numbers, crunched from Zillow and Census data by BuildZoom chief economist Issi Romem, provide more evidence of the ongoing divergence of American cities. Cities like New York or Los Angeles are getting more expensive and more productive, but not necessarily in a way that lifts everyone up. When you see data showing rising regional incomes, it’s important to remember the pool of workers in each metro area isn’t the same from year to year. “Incomes are rising for incumbents as well, but migration is helping drive income growth,” Romem says.

What these places have in common, and Romem’s baseline metric, are high housing costs that both function as a barrier to entry (discouraging low-income people from moving in) and an incentive to leave. For many years, California—whose housing prices are the highest in the country—has been shedding low-income residents by the tens of thousands each year.

Other U.S. cities show a different pattern. In Cleveland, Columbus, Cincinnati, and Pittsburgh, for example, people leaving tend to be earning more money than people arriving. They also tend to be better educated. This also sounds appealing, in a way, if you think of the city as an input-output machine of upward mobility. But these aren’t 19th-century immigrant metropolises. In practice, this data more likely represents a stream of ambitious and qualified people heading elsewhere.

All this challenges the way we measure how cities are doing. For example, it’s common to measure affordability by comparing rents to incomes. This makes sense, because people in San Francisco get paid a hell of a lot more than people in Raleigh, North Carolina, and it wouldn’t make any sense to compare housing prices without thinking about incomes. But this also creates a perverse situation: The greater number of poor people move away, the better the affordability picture looks.

Take Seattle. The city represents a kind of an outlier among U.S. cities in many ways: rising transit ridership, steady population growth despite high housing costs, lots of new apartments for a coastal city. Rent in Seattle has recently stabilized, making it a positive case study for supply-side urbanists, or YIMBYs (short for “Yes in my backyard”), arguing that rising rents can be tamed by increasing supply.

In March, though, leftists began citing Seattle as a counterexample, using a different metric. Even after all this construction, Seattle’s share of cost-burdened renters (the percentage of tenants who pay more than 30 percent of their income in rent) is very high, 46 percent. That makes Seattle look less affordable than San Francisco, in 2017 data.

In part, though, that reflects that Seattle isn’t seeing the same income-fueled migration pattern that has occurred in San Francisco and Los Angeles. In-migrants to Seattle do earn more than out-migrants—but just by a few thousand dollars, which makes it closer to equilibrium than cities like Denver, Phoenix, Tampa, and Charlotte.

In California, conversely, the affordability situation is even worse than commonly understood when you look at migration data. Californians earning less than $30,000 a year have been leaving the state in enormous numbers for the past decade, while in recent years, high earners have arrived to take their place. That may drive up housing costs, but it also makes housing appear, on paper and relative to incomes, to be more affordable. Ask your friends in California how that’s going.