This becomes tribal knowledge. The way most people become experts in these domains is by working with or around people that are already experts, which requires being in an engineering environment where you are likely to come into contact with some. This type of expertise is far from evenly distributed.
Market salaries for software engineers in Baltimore are quite a bit lower (like, 40-50% lower) than SF or NYC. Whereas for companies located in NYC/SF, they understand cost of living is high and are thus willing to pay a premium.
I'm not making a counterargument here, just saying that salaries in different areas aren't usually apples to apples.
Also, cost of living is relative: For 10 of my 17 years in NYC, I lived in a studio apartment with a 1k/month mortgage, and no car, no kids, and a lower cost of living than most of my friends in other cities. So it really depends on your family situation and what kind of environment you want to live in.
I'm curious to know what your current thoughts are behind this. As someone who intentionally has steered clear of both those areas in order to try to optimize financially I sometimes wonder whether I'm missing out on something. Obviously one can learn more from better engineers, but don't the brightest ideas from the brightest engineers wind up being written about online and/or presented at conferences at user groups and broadcast across the Internet? Or does having the opportunity to put time into a name-brand tech company for a while really increase lifelong salary or career prospects sufficiently to recover the money thrown away on rent there? Or is there really sufficient value in serendipitous collaboration/socialization to justify moving to one of these places? Is there some other question I've overlooked?