Place of residence can make a difference when it comes to staying healthy, according to a new report by WalletHub.

The personal finance website looked at the 180 most populated cities in the U.S. and rated them by using 41 key indicators of good health, with the data ranging from the costs for medical visits to fruit and vegetable consumption.

"Some places promote wellness by expanding access to nutritious food and recreational facilities," WalletHub said in its report. "Others strive to keep healthcare costs affordable for everyone or keep parks clean and well-maintained."

In the final ranking, WalletHub scored cities in four general categories: healthcare, food, fitness and green space.

The analysis showed a wide divergence among cities in some categories, according to WalletHub. For example, when looking at mental health counselors per capita, the study found a 12-fold difference between the top city in the category, Spokane, Wash., and the worst, Portland, Maine.

"Where people live can have a big influence on how successful they are at staying in good health, so the best cities are the ones that provide the greatest access to high-quality healthcare, green spaces, recreation centers and healthy food,” WalletHub analyst Cassandra Happe said in the report.

The following cities, in ascending order, were ranked as the healthiest locations in the U.S.

10. Irvine, Calif.

The city ranks 10th for fitness and 12th for healthcare.