Skip to content

Instantly share code, notes, and snippets.

View MetricMike's full-sized avatar

Michael Weigle MetricMike

View GitHub Profile
@MetricMike
MetricMike / convert_directory.sh
Created March 1, 2018 21:44
Steps for converting Shapefiles to unitedstates.io/districts
#!/bin/bash
declare -A ordinals=(["01"]="1st" ["02"]="2nd" ["03"]="3rd" ["04"]="4th" ["05"]="5th" ["06"]="6th" ["07"]="7th" ["08"]="8th" ["09"]="9th" ["10"]="10th" ["11"]="11th" ["12"]="12th" ["13"]="13th" ["14"]="14th" ["15"]="15th" ["16"]="16th" ["17"]="17th" ["18"]="18th")
for filename in pennsylvania_xa*; do
DISTRICT_NUM=$(cat ${filename} | jq -r '.features[0].id | tonumber')
DISTRICT_ID=$(cat ${filename} | jq -r '.features[0].id')
JSON_CODE="PA-${DISTRICT_ID}"
JSON_ORD=${ordinals[$DISTRICT_ID]}
JSON_DIST="Pennsylvania ${JSON_ORD}"