Do you work in San Francisco but can’t afford to live there? If so, you’re like more than 250,000 other people who schlep into the city and back five days a week.

But where to schlep from? A new study by PropertyShark factored in travel times, median home prices, school quality and crime rate and came up with a list of the 10 best places to live if you commute into the region’s biggest job center.

South San Francisco, the study found, topped the list, followed by San Bruno and San Rafael.

The study only considered cities with 30,000 or more residents that were located within a 20-mile radius of San Francisco. Commute times were given the most weight in the analysis — 40 percent of the total score — followed by median home prices at 30 percent, and school ratings and crime statistics at 15 percent each, said Patrick McGregor, the lead researcher on the study for PropertyShark.

To evaluate commute times, the researchers used averages from the 2017 American Community Survey, part of the U.S. Census, as well as the driving time from each city to San Francisco as calculated by online tools like Google Maps.

Other factors that might influence where people purchase homes, such as the availability of single-family homes or the prevalence of public transit, were not included, McGregor said.

Balancing commute times and home prices, however, led to some surprising results, like San Leandro coming in at No. 10 on the list, McGregor said. Of the cities included in the study, San Leandro was one of the furthest from San Francisco, he said, but lower average home prices helped pull it up in the rankings.

For McGregor, whose employer is based in New York, there was something else surprising about the disparities among Bay Area cities.

“We knew San Francisco was going to be more expensive than the rest of the region,” he said. “We didn’t expect to see how much more expensive it was.”

Erin Baldassari covers transportation, the Bay Area's housing shortage and breaking news. She served on the East Bay Times' 2017 Pulitzer Prize winning team for its coverage of the Ghost Ship fire. But most of all, she cares deeply about local news and hopes you do, too. If you'd like to support local journalism, please subscribe today.

More in Transportation

Q: Gary/Mr. Roadshow/Miracle Worker:My car registration renewal was due Feb. 26 — $292. I mailed a check on Feb 9. When I had not received my sticker and registration by March 4 I was afraid I would get a citation soooooo … I paid again online on March 4.They added a penalty of $53. Total paid on the credit card...

Q: With all the dollars that are supposed to be available for future road fixes, do you know if any plans are in the works to do something about the “Gates of Hades” (aka the entrance to Best Buy/Wal Mart) at Almaden Expressway and Highway 85? This design must have been the product of someone who had a grudge against...