(NEXSTAR) – What makes the perfect setting for a Fourth of July celebration? It’s not just the size of the fireworks display, according to a recent study.

From the weather to the average cost of beer and wine, WalletHub compared the 100 largest U.S. cities to determine the best one when it comes to celebrating Independence Day in 2022.

The study’s authors set out to find the perfect balance between holiday cost and fun, using 21 metrics that included average temperature, walkability, traffic congestion, average hamburger cost, duration of the fireworks show, and legality of fireworks, among others.

Source: WalletHub

When it comes to the lowest average beer and wine prices, for instance, the top five are Durham, North Carolina; Indianapolis; Fresno, California; Corpus Christi, Texas; and Milwaukee.

The highest average price, according to the study, was found in Atlanta, followed by Seattle, New York, Miami, and Hialeah, Florida.

San Francisco, which the study found to be the best city for the 2022 Fourth of July celebration, also tied for first when it came to another metric – DUI-related fatalities per capita. Along with San Francisco, Boise, Idaho; Virginia Beach, Virginia; Greensboro, North Carolina; Newark, New Jersey; and Laredo, Texas all tied for first. St. Louis and Toledo, Ohio tied for most DUI-related fatalities, followed by Memphis, Detroit, and Charlotte.

The study also gave San Francisco, among other cities, the highest possible rating for Fourth of July weather – if you decide to visit, however, keep in mind that there is always a chance of fog rolling over the city before the fireworks display begins.

The study’s authors used the 21 metrics to give weighted point scores under these umbrella categories:

  1. Fourth of July Celebrations
  2. Affordability
  3. Attractions & Activities
  4. Safety & Accessibility
  5. Fourth of July Weather Forecast

Below are the study’s top 25 cities for Fourth of July celebrations in 2022:

Overall Rank CityTotal Score Fourth of July Celebrations Affordability Attractions & Activities Safety & Accessibility Fourth of July Weather 
1San Francisco, CA73.30967261
2Los Angeles, CA73.19152364157
3Washington, DC72.665947830
4Atlanta, GA70.62360217945
5Las Vegas, NV70.02147144712
6New York, NY68.342961799
7San Diego, CA68.2878752845
8Seattle, WA67.86111001341
9Orlando, FL66.77422246281
10New Orleans, LA66.12158245830
11Miami, FL65.78662322961
12Houston, TX64.5786208971
13Chicago, IL64.06167132479
14San Antonio, TX63.522018345230
15Milwaukee, WI62.901039194484
16Cincinnati, OH62.345047124312
17Dallas, TX62.331740388212
18San Jose, CA62.2853551151
19Sacramento, CA62.28384622401
20St. Louis, MO61.49136389473
21Denver, CO61.481258113690
22Austin, TX60.721831487430
23Fremont, CA60.19247956111
24Portland, OR59.70378818301
25Cleveland, OH59.663214404651
(WalletHub)

The worst city for Fourth of July celebrations was San Bernardino, California, according to the study. Located east of Los Angeles, the city ranked dead last for attractions & activities and 99 out of 100 when it came to safety & accessibility.

Memphis, which was found to be the least safe and accessible, was 97th out of 100 when it came to the best cities to celebrate Independence Day.

Rounding out the 10 worst, according to the study, were Jersey City, New Jersey; Newark, New Jersey; Memphis, Tennessee; Winston-Salem, North Carolina; Oklahoma City, Oklahoma; St. Petersburg, Florida; Garland, Texas; Birmingham, Alabama; and Baton Rouge, Louisiana.

See the full list of all 100 cities on the WalletHub site.