|
|
We provide our Leaflet maps with shapes in the form of GeoJSON. I'm sure their are probably a number of pre-made US state and county GeoJSON files available on GitHub and such, but it's nice to know a general procedure.
|
|
|
|
|
|
For our example here, we'll create a GeoJSON file of the fifty states and Washington, D.C., and we'll try to keep it under 200KB.
|
|
|
|
|
|
### Step 1. Get geography files from the Census Bureau
|
|
|
The Census Bureau is usually the most convenient source for governmental boundaries in the US. Like many other federal agencies (*cough*, USGS, *cough*), the Census has lots of different web interfaces with slightly different features to access the same data, and the old, simple one is usually the best even though it's now hard to find from the agency's homepage.
|
|
|
|
|
|
As of 2022, this is the good one: https://www.census.gov/cgi-bin/geo/shapefiles/index.php
|
|
|
|
|
|

|
|
|
|
|
|
For our example here, we'll download US States. (It also includes "state equivalents", e.g., Puerto Rico, Guam, that we'll want to filter out later.) The year shouldn't matter for things like states or counties. It's relevant for other datasets like state legislative districts.
|
|
|
|
|
|
### Step 2. Topology-aware simplification |
|
|
\ No newline at end of file |