{"id":18455154,"url":"https://github.com/adamgibbons/oregon-choropleth","last_synced_at":"2026-02-07T01:06:12.218Z","repository":{"id":66154967,"uuid":"143316084","full_name":"adamgibbons/oregon-choropleth","owner":"adamgibbons","description":"Choropleth of Oregon's population by county","archived":false,"fork":false,"pushed_at":"2018-08-02T17:53:34.000Z","size":4798,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-16T07:12:28.266Z","etag":null,"topics":["census-data","d3-geo","maps","ndjson","oregon","shapefiles","topojson"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamgibbons.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-08-02T15:53:30.000Z","updated_at":"2018-08-02T21:41:25.000Z","dependencies_parsed_at":"2023-10-20T17:15:43.296Z","dependency_job_id":null,"html_url":"https://github.com/adamgibbons/oregon-choropleth","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"009524598ccf62803dde25e2ab15e8c852a07834"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adamgibbons/oregon-choropleth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamgibbons%2Foregon-choropleth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamgibbons%2Foregon-choropleth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamgibbons%2Foregon-choropleth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamgibbons%2Foregon-choropleth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamgibbons","download_url":"https://codeload.github.com/adamgibbons/oregon-choropleth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamgibbons%2Foregon-choropleth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29183323,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T00:44:15.062Z","status":"ssl_error","status_checked_at":"2026-02-07T00:35:01.758Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["census-data","d3-geo","maps","ndjson","oregon","shapefiles","topojson"],"created_at":"2024-11-06T08:07:17.759Z","updated_at":"2026-02-07T01:06:12.201Z","avatar_url":"https://github.com/adamgibbons.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# oregon-choropleth\n\n## Resources\n\nCounty-level data for Oregon:\n- https://www.census.gov/cgi-bin/geo/shapefiles/index.php?year=2010\u0026layergroup=Counties+%28and+equivalent%29\n\nPreview shapefiles:\n- http://mapshaper.org/\n\nGeographic projections:\n- https://github.com/veltman/d3-stateplane\n- http://spatialreference.org/\n\n## Procedure\n\nFetch Oregon county shapes\n```\nmkdir formatted raw\nmv ~/Downloads/tl_2010_41_county10.zip ./raw/\nunzip -o raw/tl_2010_41_county10.zip\n```\n\nFetch population data by county\n```\ncurl 'https://api.census.gov/data/2015/acs5?get=B01003_001E\u0026for=county:*\u0026in=state:41' -o raw/or-county-populations.json\n```\n\nConvert county data JSON array to an NDJSON stream\n- `ndjson-cat`: remove newlines\n- `ndjson-split`: split into multiple lines\n- `ndjson-map`: reformat each line as an object\n\n```\nndjson-cat raw/or-county-populations.json \\\n  | ndjson-split 'd.slice(1)' \\\n  | ndjson-map '{id: d[2], population: d[0]}' \\\n  \u003e formatted/or-county-populations.ndjson\n```\n\nConvert shapefile to GeoJSON and apply a geographic projection\n```\nshp2json raw/tl_2010_41_county10.shp \\\n    | geoproject 'd3.geoConicConformal().parallels([44 + 20 / 60, 46]).rotate([120 + 30 / 60, 0]).fitSize([960, 960], d)' \\\n    \u003e formatted/or-projected.json\n```\n\nPreview in a browser\n```\ngeo2svg -w 960 -h 960 \u003c formatted/or-projected.json \u003e formatted/or-projected.svg\n```\n\nConvert the GeoJSON feature collection to a newline-delimited stream of GeoJSON features,\nthen set each feature’s id using `ndjson-map`:\n```\nndjson-split 'd.features' \\\n  \u003c formatted/or-projected.json \\\n  | ndjson-map 'd.id = d.properties.COUNTYFP10, d' \\\n  \u003e formatted/or-projected-id.ndjson\n\n```\n\nJoin the population data to the geometry using ndjson-join,\nand remove the props we don't need\n```\nndjson-join 'd.id' formatted/or-county-populations.ndjson formatted/or-projected-id.ndjson \\\n  | ndjson-map 'd[1].properties = {population: d[0].population}, d[1]' \\\n  \u003e formatted/or-joined.ndjson\n```\n\nNow, perform some topology-preserving simplification, topoquantize, and delta-encode\n```\ngeo2topo -n \\\n  counties=formatted/or-joined.ndjson \\\n  | topoquantize 1e5 \\\n  \u003e formatted/or-topo.json\n```\n\nWe need a non-linear transform to distribute the colors equitably, so we'll use a threshold scale.\nUse `topo2geo` to extract the simplified counties from the topology,\npipe to `ndjson-map` to assign the fill property for each county,\npipe to `ndjson-split` to break the collection into features,\nand lastly pipe to `geo2svg`\n```\ntopo2geo counties=- \\\n  \u003c formatted/or-topo.json \\\n  | ndjson-map -r d3 -r d3=d3-scale-chromatic 'z = d3.scaleThreshold().domain([1000, 10000, 25000, 50000, 100000, 300000, 600000]).range(d3.schemeOrRd[9]), d.features.forEach(f =\u003e f.properties.fill = z(f.properties.population)), d' \\\n  | ndjson-split 'd.features' \\\n  | geo2svg -n --stroke none -p 1 -w 960 -h 960 \\\n  \u003e formatted/or-counties-threshold.svg\n```\n\n## Result\n![Chorolpleth of Oregon counties](https://github.com/adamgibbons/oregon-choropleth/blob/master/formatted/or-counties-threshold.svg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamgibbons%2Foregon-choropleth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamgibbons%2Foregon-choropleth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamgibbons%2Foregon-choropleth/lists"}