Skip to content

Instantly share code, notes, and snippets.

@gordonje
Created August 6, 2024 20:06
Show Gist options
  • Save gordonje/8c79625f2133851728ae5bd82314c7d3 to your computer and use it in GitHub Desktop.
Save gordonje/8c79625f2133851728ae5bd82314c7d3 to your computer and use it in GitHub Desktop.
U.S. Census Bureau Batch Geocoder

U.S. Census Bureau Batch Geocoder

Demonstrates how to make a batch geocoding service request to the U.S. Census Bureau (more info in their API docs).

Before you try this...

You need a stable connection to the internet.

The curl command-line tool must be installed and available on your PATH (more info here).

Note the provided example input file, which you can overwrite for your own purposes.

Other important notes from the API docs:

CSV formatted files should have an extension ending in .CSV, .TXT, .DAT, and Excel files should have an extension ending in .XLS, or .XLSX. The file needs to be included as part of the HTTP request.

If a component is missing from the dataset, it must still retain the delimited format with a null value. Unique ID and Street address are required fields.

If there are commas that are part of one of the fields, the whole field needs to be enclosed in quote marks for proper parsing.

There is currently an upper limit of 10,000 records per batch file.

1 207 Jackal Dr. Columbia MO
2 1251 County Road 352 Fulton MO
3 22 Bryant Walkway Columbia MO
4 12311 Hwy N Pilot Grove MO
5 10801 N. Flynt Ln Hallsville MO
6 1819 Ridgemont Avenue Columbia MO
7 4357 W. Bellview Drive Columbia MO
8 12 Atkins Dr. Columbia MO
9 4201 Clark Lane Lot 61 Columbia MO
10 22 E. Phyllis Ave Columbia MO
curl \
--form addressFile=@address_batch.csv \
--form benchmark=4 \
https://geocoding.geo.census.gov/geocoder/locations/addressbatch \
--output cb_geocode_batch.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment