Gravity Model¶
Everyone wants to see the map first, so here it is. In this article we will automate some of the analysis done in Alon Levy’s Streaming High-Speed Rail Crayoning. Mostly we will focus on the Gravity Model which is explained below.
Note: this notebook has been updated to use population-weighted centroids (instead of geometric centroids) for the Combined Statistical Areas (CSA) and a multi-index for the CSA DataFrame.
First we will import the libraries necessary for gathering data, performing our analysis, and plotting the results.
[1]:
import contextily as ctx
import folium
import geopandas
from numpy import inf
import pandas
from shapely.geometry import LineString
import ssl
ssl._create_default_https_context = ssl._create_stdlib_context
from dpd.modeling import DistanceDataFrame, TripDataFrame
pandas.set_option("display.max_columns", None)
pandas.set_option("display.max_rows", None)
Thanks to Kevin Wilson for creating a geojson file of population-weighted Combined Statistical Areas (CSA) and their corresponding populations. We can easily load this file directly as a GeoPandas GeoDataFrame.
[2]:
csa = geopandas.read_file(
"https://gist.githubusercontent.com/khwilson/2df2f86bc444d020b59a9ebe61b7944b/raw/4611d5a54dc976a17a6429e1a1d5deb628861069/csa_population_weighted_centroids.geojson"
)
csa.head()
[2]:
csa_fp | csa_name | population | geometry | |
---|---|---|---|---|
0 | 104 | Albany-Schenectady, NY | 1170877 | POINT (-73.83270 42.84156) |
1 | 106 | Albuquerque-Santa Fe-Las Vegas, NM | 1149189 | POINT (-106.48704 35.24134) |
2 | 107 | Altoona-Huntingdon, PA | 169263 | POINT (-78.27657 40.47080) |
3 | 108 | Amarillo-Pampa-Borger, TX | 308553 | POINT (-101.75521 35.23698) |
4 | 118 | Appleton-Oshkosh-Neenah, WI | 404487 | POINT (-88.44143 44.20267) |
We can use Folium to plot the CSAs on OpenStreetMap. Some cities like San Diego and Tampa are missing because they are outside a CSA. Note that we now use population-weighted centroids for each CSA.
[3]:
style_function = lambda x: {"radius": x["properties"]["population"] / 1000000}
csa.explore(style_kwds={"style_function": style_function})
[3]:
In the next step, we will implenent our Gravity Model and use it to predict the ridership between all CSAs. The Gravity Model for our analysis is
$ Annual Traffic Volume = G \times `:nbsphinx-math:frac{(Originpopulation)^{a}times(Destinationpopulation)^{b}}{(Distancebetweenoriginanddestination)^{d}}` $
In the case of high speed rail, G=75,000, a=b=0.8, and d=2. Also, if the distance is less than 500km, we set distance to 500km. (These numbers are all from the article Metcalfe’s Law for High-Speed Rail). The results of this step is a table with the predicted ridership between CSAs. I’ve dropped rows/columns where the predicted ridership is below 1 million people/year.
[4]:
distance_dataframe = (
DistanceDataFrame.from_origins_destinations(
origins=csa.geometry, destinations=csa.geometry, method="haversine"
)
/ 1000
)
distance_dataframe = distance_dataframe.where(distance_dataframe != 0, inf)
distance_dataframe = distance_dataframe.where(distance_dataframe >= 500, 500)
trip_dataframe = TripDataFrame.from_gravity_model(
csa.population / 1000000,
csa.population / 1000000,
distance_dataframe,
G=75000,
a=0.8,
b=0.8,
d=2,
)
trip_dataframe.index = csa.csa_name
trip_dataframe.columns = csa.csa_name
series = trip_dataframe.stack().astype(int)
series.name = "Millions of Annual Passengers"
series = series[series > 0]
pandas.DataFrame(series)
[4]:
Millions of Annual Passengers | ||
---|---|---|
csa_name | csa_name | |
Albany-Schenectady, NY | Boston-Worcester-Providence, MA-RI-NH-CT | 1 |
New York-Newark, NY-NJ-CT-PA | 4 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 2 | |
Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | Birmingham-Hoover-Talladega, AL | 1 |
Charlotte-Concord, NC-SC | 2 | |
Chattanooga-Cleveland-Dalton, TN-GA | 1 | |
Chicago-Naperville, IL-IN-WI | 2 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 1 | |
Cleveland-Akron-Canton, OH | 1 | |
Columbia-Orangeburg-Newberry, SC | 1 | |
Columbus-Marion-Zanesville, OH | 1 | |
Dallas-Fort Worth, TX-OK | 1 | |
Detroit-Warren-Ann Arbor, MI | 1 | |
Fayetteville-Sanford-Lumberton, NC | 1 | |
Greensboro--Winston-Salem--High Point, NC | 2 | |
Greenville-Spartanburg-Anderson, SC | 1 | |
Houston-The Woodlands, TX | 1 | |
Indianapolis-Carmel-Muncie, IN | 1 | |
Jacksonville-St. Marys-Palatka, FL-GA | 1 | |
Knoxville-Morristown-Sevierville, TN | 1 | |
Lexington-Fayette--Richmond--Frankfort, KY | 1 | |
Louisville/Jefferson County--Elizabethtown--Bardstown, KY-IN | 1 | |
Memphis-Forrest City, TN-MS-AR | 1 | |
Miami-Port St. Lucie-Fort Lauderdale, FL | 1 | |
Nashville-Davidson--Murfreesboro, TN | 2 | |
New York-Newark, NY-NJ-CT-PA | 2 | |
Orlando-Lakeland-Deltona, FL | 2 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 1 | |
Raleigh-Durham-Cary, NC | 1 | |
St. Louis-St. Charles-Farmington, MO-IL | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 2 | |
Birmingham-Hoover-Talladega, AL | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Bloomsburg-Berwick-Sunbury, PA | New York-Newark, NY-NJ-CT-PA | 1 |
Boston-Worcester-Providence, MA-RI-NH-CT | Albany-Schenectady, NY | 1 |
Buffalo-Cheektowaga-Olean, NY | 1 | |
Chicago-Naperville, IL-IN-WI | 1 | |
Cleveland-Akron-Canton, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 1 | |
Harrisburg-York-Lebanon, PA | 1 | |
Hartford-East Hartford, CT | 2 | |
New York-Newark, NY-NJ-CT-PA | 19 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 7 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 1 | |
Portland-Lewiston-South Portland, ME | 1 | |
Rochester-Batavia-Seneca Falls, NY | 1 | |
Syracuse-Auburn, NY | 1 | |
Virginia Beach-Norfolk, VA-NC | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 6 | |
Buffalo-Cheektowaga-Olean, NY | Boston-Worcester-Providence, MA-RI-NH-CT | 1 |
Detroit-Warren-Ann Arbor, MI | 1 | |
New York-Newark, NY-NJ-CT-PA | 4 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 2 | |
Burlington-South Burlington-Barre, VT | New York-Newark, NY-NJ-CT-PA | 1 |
Cape Coral-Fort Myers-Naples, FL | Miami-Port St. Lucie-Fort Lauderdale, FL | 1 |
Charleston-Huntington-Ashland, WV-OH-KY | Chicago-Naperville, IL-IN-WI | 1 |
New York-Newark, NY-NJ-CT-PA | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 1 | |
Charlotte-Concord, NC-SC | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 2 |
Chicago-Naperville, IL-IN-WI | 1 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 1 | |
Cleveland-Akron-Canton, OH | 1 | |
Columbus-Marion-Zanesville, OH | 1 | |
New York-Newark, NY-NJ-CT-PA | 2 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 1 | |
Raleigh-Durham-Cary, NC | 1 | |
Virginia Beach-Norfolk, VA-NC | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 3 | |
Chattanooga-Cleveland-Dalton, TN-GA | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Chicago-Naperville, IL-IN-WI | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 2 |
Boston-Worcester-Providence, MA-RI-NH-CT | 1 | |
Charleston-Huntington-Ashland, WV-OH-KY | 1 | |
Charlotte-Concord, NC-SC | 1 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 3 | |
Cleveland-Akron-Canton, OH | 4 | |
Columbus-Marion-Zanesville, OH | 3 | |
Dallas-Fort Worth, TX-OK | 1 | |
Davenport-Moline, IA-IL | 1 | |
Dayton-Springfield-Kettering, OH | 1 | |
Des Moines-Ames-West Des Moines, IA | 1 | |
Detroit-Warren-Ann Arbor, MI | 7 | |
Fort Wayne-Huntington-Auburn, IN | 1 | |
Grand Rapids-Kentwood-Muskegon, MI | 2 | |
Indianapolis-Carmel-Muncie, IN | 3 | |
Kalamazoo-Battle Creek-Portage, MI | 1 | |
Kansas City-Overland Park-Kansas City, MO-KS | 2 | |
Lexington-Fayette--Richmond--Frankfort, KY | 1 | |
Louisville/Jefferson County--Elizabethtown--Bardstown, KY-IN | 2 | |
Madison-Janesville-Beloit, WI | 1 | |
Memphis-Forrest City, TN-MS-AR | 1 | |
Milwaukee-Racine-Waukesha, WI | 3 | |
Minneapolis-St. Paul, MN-WI | 4 | |
Nashville-Davidson--Murfreesboro, TN | 1 | |
New York-Newark, NY-NJ-CT-PA | 4 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 2 | |
St. Louis-St. Charles-Farmington, MO-IL | 4 | |
South Bend-Elkhart-Mishawaka, IN-MI | 1 | |
Toledo-Findlay-Tiffin, OH | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 3 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Charlotte-Concord, NC-SC | 1 | |
Chicago-Naperville, IL-IN-WI | 3 | |
Cleveland-Akron-Canton, OH | 1 | |
Columbus-Marion-Zanesville, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 2 | |
Indianapolis-Carmel-Muncie, IN | 1 | |
New York-Newark, NY-NJ-CT-PA | 2 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 1 | |
St. Louis-St. Charles-Farmington, MO-IL | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 2 | |
Cleveland-Akron-Canton, OH | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Boston-Worcester-Providence, MA-RI-NH-CT | 1 | |
Charlotte-Concord, NC-SC | 1 | |
Chicago-Naperville, IL-IN-WI | 4 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 1 | |
Columbus-Marion-Zanesville, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 3 | |
Grand Rapids-Kentwood-Muskegon, MI | 1 | |
Harrisburg-York-Lebanon, PA | 1 | |
Indianapolis-Carmel-Muncie, IN | 1 | |
Louisville/Jefferson County--Elizabethtown--Bardstown, KY-IN | 1 | |
Milwaukee-Racine-Waukesha, WI | 1 | |
New York-Newark, NY-NJ-CT-PA | 6 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 3 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 5 | |
Columbia-Orangeburg-Newberry, SC | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Columbus-Marion-Zanesville, OH | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Charlotte-Concord, NC-SC | 1 | |
Chicago-Naperville, IL-IN-WI | 3 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 1 | |
Cleveland-Akron-Canton, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 2 | |
Indianapolis-Carmel-Muncie, IN | 1 | |
New York-Newark, NY-NJ-CT-PA | 3 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 3 | |
Dallas-Fort Worth, TX-OK | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Chicago-Naperville, IL-IN-WI | 1 | |
Houston-The Woodlands, TX | 7 | |
Kansas City-Overland Park-Kansas City, MO-KS | 1 | |
Little Rock-North Little Rock, AR | 1 | |
Los Angeles-Long Beach, CA | 1 | |
Memphis-Forrest City, TN-MS-AR | 1 | |
New Orleans-Metairie-Hammond, LA-MS | 1 | |
Oklahoma City-Shawnee, OK | 2 | |
St. Louis-St. Charles-Farmington, MO-IL | 1 | |
San Antonio-New Braunfels-Pearsall, TX | 3 | |
Tulsa-Muskogee-Bartlesville, OK | 1 | |
Davenport-Moline, IA-IL | Chicago-Naperville, IL-IN-WI | 1 |
Dayton-Springfield-Kettering, OH | Chicago-Naperville, IL-IN-WI | 1 |
Detroit-Warren-Ann Arbor, MI | 1 | |
New York-Newark, NY-NJ-CT-PA | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 1 | |
Denver-Aurora, CO | Los Angeles-Long Beach, CA | 1 |
Salt Lake City-Provo-Orem, UT | 1 | |
Des Moines-Ames-West Des Moines, IA | Chicago-Naperville, IL-IN-WI | 1 |
Detroit-Warren-Ann Arbor, MI | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Boston-Worcester-Providence, MA-RI-NH-CT | 1 | |
Buffalo-Cheektowaga-Olean, NY | 1 | |
Chicago-Naperville, IL-IN-WI | 7 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 2 | |
Cleveland-Akron-Canton, OH | 3 | |
Columbus-Marion-Zanesville, OH | 2 | |
Dayton-Springfield-Kettering, OH | 1 | |
Grand Rapids-Kentwood-Muskegon, MI | 1 | |
Indianapolis-Carmel-Muncie, IN | 2 | |
Louisville/Jefferson County--Elizabethtown--Bardstown, KY-IN | 1 | |
Madison-Janesville-Beloit, WI | 1 | |
Milwaukee-Racine-Waukesha, WI | 2 | |
Minneapolis-St. Paul, MN-WI | 1 | |
New York-Newark, NY-NJ-CT-PA | 5 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 2 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 2 | |
Rochester-Batavia-Seneca Falls, NY | 1 | |
St. Louis-St. Charles-Farmington, MO-IL | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 4 | |
Erie-Meadville, PA | New York-Newark, NY-NJ-CT-PA | 1 |
Fayetteville-Sanford-Lumberton, NC | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
New York-Newark, NY-NJ-CT-PA | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 1 | |
Fort Wayne-Huntington-Auburn, IN | Chicago-Naperville, IL-IN-WI | 1 |
Fresno-Madera-Hanford, CA | Los Angeles-Long Beach, CA | 3 |
San Jose-San Francisco-Oakland, CA | 2 | |
Grand Rapids-Kentwood-Muskegon, MI | Chicago-Naperville, IL-IN-WI | 2 |
Cleveland-Akron-Canton, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 1 | |
New York-Newark, NY-NJ-CT-PA | 1 | |
Greensboro--Winston-Salem--High Point, NC | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 2 |
New York-Newark, NY-NJ-CT-PA | 2 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 2 | |
Greenville-Spartanburg-Anderson, SC | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
New York-Newark, NY-NJ-CT-PA | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 1 | |
Harrisburg-York-Lebanon, PA | Boston-Worcester-Providence, MA-RI-NH-CT | 1 |
Cleveland-Akron-Canton, OH | 1 | |
New York-Newark, NY-NJ-CT-PA | 4 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 2 | |
Harrisonburg-Staunton, VA | New York-Newark, NY-NJ-CT-PA | 1 |
Hartford-East Hartford, CT | Boston-Worcester-Providence, MA-RI-NH-CT | 2 |
New York-Newark, NY-NJ-CT-PA | 4 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 2 | |
Houston-The Woodlands, TX | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Dallas-Fort Worth, TX-OK | 7 | |
McAllen-Edinburg, TX | 1 | |
New Orleans-Metairie-Hammond, LA-MS | 1 | |
Oklahoma City-Shawnee, OK | 1 | |
San Antonio-New Braunfels-Pearsall, TX | 2 | |
Indianapolis-Carmel-Muncie, IN | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Chicago-Naperville, IL-IN-WI | 3 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 1 | |
Cleveland-Akron-Canton, OH | 1 | |
Columbus-Marion-Zanesville, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 2 | |
Milwaukee-Racine-Waukesha, WI | 1 | |
Nashville-Davidson--Murfreesboro, TN | 1 | |
New York-Newark, NY-NJ-CT-PA | 1 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 1 | |
St. Louis-St. Charles-Farmington, MO-IL | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 1 | |
Jacksonville-St. Marys-Palatka, FL-GA | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Miami-Port St. Lucie-Fort Lauderdale, FL | 2 | |
Orlando-Lakeland-Deltona, FL | 1 | |
Johnstown-Somerset, PA | New York-Newark, NY-NJ-CT-PA | 1 |
Kalamazoo-Battle Creek-Portage, MI | Chicago-Naperville, IL-IN-WI | 1 |
Kansas City-Overland Park-Kansas City, MO-KS | Chicago-Naperville, IL-IN-WI | 2 |
Dallas-Fort Worth, TX-OK | 1 | |
Minneapolis-St. Paul, MN-WI | 1 | |
St. Louis-St. Charles-Farmington, MO-IL | 1 | |
Knoxville-Morristown-Sevierville, TN | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 1 | |
Las Vegas-Henderson, NV | Los Angeles-Long Beach, CA | 5 |
Phoenix-Mesa, AZ | 1 | |
San Jose-San Francisco-Oakland, CA | 2 | |
Lexington-Fayette--Richmond--Frankfort, KY | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Chicago-Naperville, IL-IN-WI | 1 | |
Little Rock-North Little Rock, AR | Dallas-Fort Worth, TX-OK | 1 |
Los Angeles-Long Beach, CA | Dallas-Fort Worth, TX-OK | 1 |
Denver-Aurora, CO | 1 | |
Fresno-Madera-Hanford, CA | 3 | |
Las Vegas-Henderson, NV | 5 | |
Phoenix-Mesa, AZ | 8 | |
Portland-Vancouver-Salem, OR-WA | 1 | |
Reno-Carson City-Fernley, NV | 1 | |
Sacramento-Roseville, CA | 4 | |
Salt Lake City-Provo-Orem, UT | 1 | |
San Jose-San Francisco-Oakland, CA | 15 | |
Seattle-Tacoma, WA | 1 | |
Tucson-Nogales, AZ | 1 | |
Louisville/Jefferson County--Elizabethtown--Bardstown, KY-IN | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Chicago-Naperville, IL-IN-WI | 2 | |
Cleveland-Akron-Canton, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 1 | |
New York-Newark, NY-NJ-CT-PA | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 1 | |
Madison-Janesville-Beloit, WI | Chicago-Naperville, IL-IN-WI | 1 |
Detroit-Warren-Ann Arbor, MI | 1 | |
McAllen-Edinburg, TX | Houston-The Woodlands, TX | 1 |
Memphis-Forrest City, TN-MS-AR | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Chicago-Naperville, IL-IN-WI | 1 | |
Dallas-Fort Worth, TX-OK | 1 | |
Miami-Port St. Lucie-Fort Lauderdale, FL | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Cape Coral-Fort Myers-Naples, FL | 1 | |
Jacksonville-St. Marys-Palatka, FL-GA | 2 | |
New York-Newark, NY-NJ-CT-PA | 1 | |
North Port-Sarasota, FL | 1 | |
Orlando-Lakeland-Deltona, FL | 4 | |
Milwaukee-Racine-Waukesha, WI | Chicago-Naperville, IL-IN-WI | 3 |
Cleveland-Akron-Canton, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 2 | |
Indianapolis-Carmel-Muncie, IN | 1 | |
Minneapolis-St. Paul, MN-WI | 1 | |
New York-Newark, NY-NJ-CT-PA | 1 | |
St. Louis-St. Charles-Farmington, MO-IL | 1 | |
Minneapolis-St. Paul, MN-WI | Chicago-Naperville, IL-IN-WI | 4 |
Detroit-Warren-Ann Arbor, MI | 1 | |
Kansas City-Overland Park-Kansas City, MO-KS | 1 | |
Milwaukee-Racine-Waukesha, WI | 1 | |
New York-Newark, NY-NJ-CT-PA | 1 | |
Nashville-Davidson--Murfreesboro, TN | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 2 |
Chicago-Naperville, IL-IN-WI | 1 | |
Indianapolis-Carmel-Muncie, IN | 1 | |
New York-Newark, NY-NJ-CT-PA | 1 | |
St. Louis-St. Charles-Farmington, MO-IL | 1 | |
New Orleans-Metairie-Hammond, LA-MS | Dallas-Fort Worth, TX-OK | 1 |
Houston-The Woodlands, TX | 1 | |
New York-Newark, NY-NJ-CT-PA | Albany-Schenectady, NY | 4 |
Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 2 | |
Bloomsburg-Berwick-Sunbury, PA | 1 | |
Boston-Worcester-Providence, MA-RI-NH-CT | 19 | |
Buffalo-Cheektowaga-Olean, NY | 4 | |
Burlington-South Burlington-Barre, VT | 1 | |
Charleston-Huntington-Ashland, WV-OH-KY | 1 | |
Charlotte-Concord, NC-SC | 2 | |
Chicago-Naperville, IL-IN-WI | 4 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 2 | |
Cleveland-Akron-Canton, OH | 6 | |
Columbus-Marion-Zanesville, OH | 3 | |
Dayton-Springfield-Kettering, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 5 | |
Erie-Meadville, PA | 1 | |
Fayetteville-Sanford-Lumberton, NC | 1 | |
Grand Rapids-Kentwood-Muskegon, MI | 1 | |
Greensboro--Winston-Salem--High Point, NC | 2 | |
Greenville-Spartanburg-Anderson, SC | 1 | |
Harrisburg-York-Lebanon, PA | 4 | |
Harrisonburg-Staunton, VA | 1 | |
Hartford-East Hartford, CT | 4 | |
Indianapolis-Carmel-Muncie, IN | 1 | |
Johnstown-Somerset, PA | 1 | |
Louisville/Jefferson County--Elizabethtown--Bardstown, KY-IN | 1 | |
Miami-Port St. Lucie-Fort Lauderdale, FL | 1 | |
Milwaukee-Racine-Waukesha, WI | 1 | |
Minneapolis-St. Paul, MN-WI | 1 | |
Nashville-Davidson--Murfreesboro, TN | 1 | |
Orlando-Lakeland-Deltona, FL | 1 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 17 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 7 | |
Portland-Lewiston-South Portland, ME | 2 | |
Raleigh-Durham-Cary, NC | 3 | |
Rochester-Batavia-Seneca Falls, NY | 4 | |
St. Louis-St. Charles-Farmington, MO-IL | 1 | |
Salisbury-Cambridge, MD-DE | 1 | |
State College-DuBois, PA | 1 | |
Syracuse-Auburn, NY | 2 | |
Toledo-Findlay-Tiffin, OH | 1 | |
Virginia Beach-Norfolk, VA-NC | 5 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 22 | |
Youngstown-Warren, OH-PA | 2 | |
North Port-Sarasota, FL | Miami-Port St. Lucie-Fort Lauderdale, FL | 1 |
Oklahoma City-Shawnee, OK | Dallas-Fort Worth, TX-OK | 2 |
Houston-The Woodlands, TX | 1 | |
Orlando-Lakeland-Deltona, FL | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 2 |
Jacksonville-St. Marys-Palatka, FL-GA | 1 | |
Miami-Port St. Lucie-Fort Lauderdale, FL | 4 | |
New York-Newark, NY-NJ-CT-PA | 1 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | Albany-Schenectady, NY | 1 |
Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 | |
Boston-Worcester-Providence, MA-RI-NH-CT | 7 | |
Buffalo-Cheektowaga-Olean, NY | 1 | |
Charlotte-Concord, NC-SC | 1 | |
Chicago-Naperville, IL-IN-WI | 1 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 1 | |
Cleveland-Akron-Canton, OH | 3 | |
Columbus-Marion-Zanesville, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 2 | |
Greensboro--Winston-Salem--High Point, NC | 1 | |
Harrisburg-York-Lebanon, PA | 1 | |
Hartford-East Hartford, CT | 1 | |
New York-Newark, NY-NJ-CT-PA | 17 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 3 | |
Raleigh-Durham-Cary, NC | 2 | |
Rochester-Batavia-Seneca Falls, NY | 1 | |
Syracuse-Auburn, NY | 1 | |
Virginia Beach-Norfolk, VA-NC | 2 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 8 | |
Youngstown-Warren, OH-PA | 1 | |
Phoenix-Mesa, AZ | Las Vegas-Henderson, NV | 1 |
Los Angeles-Long Beach, CA | 8 | |
San Jose-San Francisco-Oakland, CA | 1 | |
Tucson-Nogales, AZ | 1 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Boston-Worcester-Providence, MA-RI-NH-CT | 1 | |
Charlotte-Concord, NC-SC | 1 | |
Chicago-Naperville, IL-IN-WI | 2 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 1 | |
Cleveland-Akron-Canton, OH | 1 | |
Columbus-Marion-Zanesville, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 2 | |
Indianapolis-Carmel-Muncie, IN | 1 | |
New York-Newark, NY-NJ-CT-PA | 7 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 3 | |
Raleigh-Durham-Cary, NC | 1 | |
Virginia Beach-Norfolk, VA-NC | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 3 | |
Portland-Lewiston-South Portland, ME | Boston-Worcester-Providence, MA-RI-NH-CT | 1 |
New York-Newark, NY-NJ-CT-PA | 2 | |
Portland-Vancouver-Salem, OR-WA | Los Angeles-Long Beach, CA | 1 |
San Jose-San Francisco-Oakland, CA | 1 | |
Seattle-Tacoma, WA | 2 | |
Raleigh-Durham-Cary, NC | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Charlotte-Concord, NC-SC | 1 | |
New York-Newark, NY-NJ-CT-PA | 3 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 2 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 3 | |
Reno-Carson City-Fernley, NV | Los Angeles-Long Beach, CA | 1 |
San Jose-San Francisco-Oakland, CA | 1 | |
Rochester-Batavia-Seneca Falls, NY | Boston-Worcester-Providence, MA-RI-NH-CT | 1 |
Detroit-Warren-Ann Arbor, MI | 1 | |
New York-Newark, NY-NJ-CT-PA | 4 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 2 | |
Sacramento-Roseville, CA | Los Angeles-Long Beach, CA | 4 |
San Jose-San Francisco-Oakland, CA | 3 | |
St. Louis-St. Charles-Farmington, MO-IL | Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 1 |
Chicago-Naperville, IL-IN-WI | 4 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 1 | |
Dallas-Fort Worth, TX-OK | 1 | |
Detroit-Warren-Ann Arbor, MI | 1 | |
Indianapolis-Carmel-Muncie, IN | 1 | |
Kansas City-Overland Park-Kansas City, MO-KS | 1 | |
Milwaukee-Racine-Waukesha, WI | 1 | |
Nashville-Davidson--Murfreesboro, TN | 1 | |
New York-Newark, NY-NJ-CT-PA | 1 | |
Salisbury-Cambridge, MD-DE | New York-Newark, NY-NJ-CT-PA | 1 |
Salt Lake City-Provo-Orem, UT | Denver-Aurora, CO | 1 |
Los Angeles-Long Beach, CA | 1 | |
San Jose-San Francisco-Oakland, CA | 1 | |
San Antonio-New Braunfels-Pearsall, TX | Dallas-Fort Worth, TX-OK | 3 |
Houston-The Woodlands, TX | 2 | |
San Jose-San Francisco-Oakland, CA | Fresno-Madera-Hanford, CA | 2 |
Las Vegas-Henderson, NV | 2 | |
Los Angeles-Long Beach, CA | 15 | |
Phoenix-Mesa, AZ | 1 | |
Portland-Vancouver-Salem, OR-WA | 1 | |
Reno-Carson City-Fernley, NV | 1 | |
Sacramento-Roseville, CA | 3 | |
Salt Lake City-Provo-Orem, UT | 1 | |
Seattle-Tacoma, WA | 1 | |
Seattle-Tacoma, WA | Los Angeles-Long Beach, CA | 1 |
Portland-Vancouver-Salem, OR-WA | 2 | |
San Jose-San Francisco-Oakland, CA | 1 | |
South Bend-Elkhart-Mishawaka, IN-MI | Chicago-Naperville, IL-IN-WI | 1 |
State College-DuBois, PA | New York-Newark, NY-NJ-CT-PA | 1 |
Syracuse-Auburn, NY | Boston-Worcester-Providence, MA-RI-NH-CT | 1 |
New York-Newark, NY-NJ-CT-PA | 2 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 1 | |
Toledo-Findlay-Tiffin, OH | Chicago-Naperville, IL-IN-WI | 1 |
New York-Newark, NY-NJ-CT-PA | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 1 | |
Tucson-Nogales, AZ | Los Angeles-Long Beach, CA | 1 |
Phoenix-Mesa, AZ | 1 | |
Tulsa-Muskogee-Bartlesville, OK | Dallas-Fort Worth, TX-OK | 1 |
Virginia Beach-Norfolk, VA-NC | Boston-Worcester-Providence, MA-RI-NH-CT | 1 |
Charlotte-Concord, NC-SC | 1 | |
New York-Newark, NY-NJ-CT-PA | 5 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 2 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 3 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | Albany-Schenectady, NY | 2 |
Atlanta--Athens-Clarke County--Sandy Springs, GA-AL | 2 | |
Boston-Worcester-Providence, MA-RI-NH-CT | 6 | |
Buffalo-Cheektowaga-Olean, NY | 2 | |
Charleston-Huntington-Ashland, WV-OH-KY | 1 | |
Charlotte-Concord, NC-SC | 3 | |
Chicago-Naperville, IL-IN-WI | 3 | |
Cincinnati-Wilmington-Maysville, OH-KY-IN | 2 | |
Cleveland-Akron-Canton, OH | 5 | |
Columbus-Marion-Zanesville, OH | 3 | |
Dayton-Springfield-Kettering, OH | 1 | |
Detroit-Warren-Ann Arbor, MI | 4 | |
Fayetteville-Sanford-Lumberton, NC | 1 | |
Greensboro--Winston-Salem--High Point, NC | 2 | |
Greenville-Spartanburg-Anderson, SC | 1 | |
Harrisburg-York-Lebanon, PA | 2 | |
Hartford-East Hartford, CT | 2 | |
Indianapolis-Carmel-Muncie, IN | 1 | |
Knoxville-Morristown-Sevierville, TN | 1 | |
Louisville/Jefferson County--Elizabethtown--Bardstown, KY-IN | 1 | |
New York-Newark, NY-NJ-CT-PA | 22 | |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 8 | |
Pittsburgh-New Castle-Weirton, PA-OH-WV | 3 | |
Raleigh-Durham-Cary, NC | 3 | |
Rochester-Batavia-Seneca Falls, NY | 2 | |
Syracuse-Auburn, NY | 1 | |
Toledo-Findlay-Tiffin, OH | 1 | |
Virginia Beach-Norfolk, VA-NC | 3 | |
Youngstown-Warren, OH-PA | 1 | |
Youngstown-Warren, OH-PA | New York-Newark, NY-NJ-CT-PA | 2 |
Philadelphia-Reading-Camden, PA-NJ-DE-MD | 1 | |
Washington-Baltimore-Arlington, DC-MD-VA-WV-PA | 1 |
Now we can plot these city pairs on a map. We will limit this plot to pairs with ridership potential above 2 million people/year. Line width is based on ridership potential. This map looks very famaliar to Alon Levy’s map. California, Texas, Florida, the Midwest, and the Northeast Corridor all have strong potential for high-speed rail. There is not a strong potential for cross-country high-speed rail. Note that this analysis ignores many factors such as geography, cost, cooperation between routes, and cultural/societal factors. It also ignores international routes.
[5]:
series = series[series > 1]
linestrings = []
for origin, destination in series.index:
linestrings.append(
{
"geometry": LineString(
[
csa[csa["csa_name"] == origin]["geometry"].iloc[0],
csa[csa["csa_name"] == destination]["geometry"].iloc[0],
]
),
"passengers": series[origin][destination],
}
)
routes = geopandas.GeoDataFrame(linestrings)
routes.crs = csa.crs
[6]:
style_function = lambda x: {"weight": x["properties"]["passengers"]}
m = routes.explore(style_kwds={"style_function": style_function})
style_function = lambda x: {"radius": x["properties"]["population"] / 1000000}
csa.explore(m=m, style_kwds={"style_function": style_function})
[6]:
Last we can also plot the map as a png.
[7]:
routes.to_crs(epsg=3857, inplace=True)
ax = routes.plot(figsize=(18, 10), color="black")
ctx.add_basemap(ax, zoom=6)
ax.set_axis_off()
fig = ax.get_figure()
fig.savefig("gravity_model.png")
Below is my previous code for getting the list of Combined Statistical Areas (CSA) with their 2019 populations from Wikipedia. I also computed the geometric centroid of each CSA based on data from the United States Census Bureau. I then combined these two tables to create a table with both population and geometry. This has been replaced by Kevin Wilson’s file above.
[8]:
from dpd.wikipedia import get_wikipedia_table
from dpd.utils import download_file
url = "https://en.wikipedia.org/wiki/Combined_statistical_area"
wikipeida_csa = get_wikipedia_table(url, 1)
wikipeida_csa["Combined\xa0statistical\xa0area"] = wikipeida_csa[
"Combined\xa0statistical\xa0area"
].map(lambda x: x.replace("Combined Statistical Area", "CSA"))
wikipeida_csa["2023 estimate"] = wikipeida_csa["2023 estimate"].map(
lambda x: int(x.replace(",", ""))
)
url = "https://www2.census.gov/geo/tiger/TIGER2020/CSA/tl_2020_us_csa.zip"
tiger_file = download_file(url)
tiger = geopandas.GeoDataFrame.from_file(tiger_file)
tiger["NAMELSAD"] = tiger["NAMELSAD"].map(lambda x: x.replace("--", "–"))
tiger["geometry"] = tiger["geometry"].map(lambda x: x.centroid)
csa = pandas.merge(
tiger,
wikipeida_csa,
left_on="NAMELSAD",
right_on="Combined\xa0statistical\xa0area",
how="inner",
)
csa.head()
[8]:
CSAFP | GEOID | NAME | NAMELSAD | LSAD | MTFCC | ALAND | AWATER | INTPTLAT | INTPTLON | geometry | Rank | Combined statistical area | 2023 estimate | 2020 census | Change | Constituent core-based statistical areas | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 122 | 122 | Atlanta--Athens-Clarke County--Sandy Springs, ... | Atlanta–Athens-Clarke County–Sandy Springs, GA... | M0 | G3100 | 33807581912 | 671939141 | +33.7282990 | -084.3477277 | POINT (-84.34640 33.72930) | 10 | Atlanta–Athens-Clarke County–Sandy Springs, GA... | 7221137 | 6,976,171 | +3.51% | Atlanta–Sandy Springs–Roswell, GA MSAAthens-Cl... |
1 | 268 | 268 | Greensboro--Winston-Salem--High Point, NC | Greensboro–Winston-Salem–High Point, NC CSA | M0 | G3100 | 12843782512 | 188393286 | +36.0898649 | -080.0782124 | POINT (-80.07848 36.08964) | 37 | Greensboro–Winston-Salem–High Point, NC CSA | 1736099 | 1,695,306 | +2.41% | Greensboro–High Point, NC MSAWinston-Salem, NC... |
2 | 336 | 336 | Lexington-Fayette--Richmond--Frankfort, KY | Lexington-Fayette–Richmond–Frankfort, KY CSA | M0 | G3100 | 8417748773 | 98653161 | +38.0121784 | -084.2828585 | POINT (-84.29594 38.00613) | 71 | Lexington-Fayette–Richmond–Frankfort, KY CSA | 770951 | 762,082 | +1.16% | Lexington-Fayette, KY MSARichmond–Berea, KY μS... |
3 | 356 | 356 | Macon-Bibb County--Warner Robins, GA | Macon-Bibb County–Warner Robins, GA CSA | M0 | G3100 | 5827265752 | 49165153 | +32.7904197 | -083.7277906 | POINT (-83.71424 32.77194) | 95 | Macon-Bibb County–Warner Robins, GA CSA | 436853 | 425,416 | +2.69% | Macon-Bibb County, GA MSAWarner Robins, GA MSA |
4 | 400 | 400 | Nashville-Davidson--Murfreesboro, TN | Nashville-Davidson–Murfreesboro, TN CSA | M0 | G3100 | 18533118439 | 204084715 | +35.9686460 | -086.7069821 | POINT (-86.70272 35.96987) | 32 | Nashville-Davidson–Murfreesboro, TN CSA | 2350738 | 2,250,282 | +4.46% | Nashville-Davidson–Murfreesboro–Franklin, TN M... |
[ ]: