Distances between State Population Centers and State Capitals

Distance between Population Center and State Capital.png

Leaflet Map
What’s the best spot for a state capital? I chose to compare the capital with the state’s population center. The population center of a state is the point at which a flat surface representation of the state would balance if weights of identical size were placed on it so that each weight represented the location of one person. It’s like the center of gravity of an object. The population center in my opinion is the optimal spot for a capital, because it minimizes everyone’s combined travel distance to and from the capital.
This was the first time I had created my own script in Python. I relied on Geoff Boeing’s Getting Started with Python.

From the distance data, I created a map displaying population centers, capitals, and a line connecting them, colored by distance. This was also my first time working with Leaflet. My starting point was Geoff Boeing’s Exporting Python Data to GeoJSON. The first step was creating the GeoJSON that the map would display. I wrote a script to create a .js file holding the GeoJSON for the capital and population center points. Then I wrote a script to create the GeoJSON for the lines.

After the data files were made, it was time to set up the HTML and JavaScript. Once again, I used an article from Geoff Boeing.  To color the lines based on the distance value, I used Chroma.js. Lines are treated differently than points, so I used a different way to style them and create the popup when clicked.

1.PNG

2.PNG

3

Leave a Reply

Your email address will not be published. Required fields are marked *