Skip to content

Instantly share code, notes, and snippets.

@daigofuji
Created September 14, 2022 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daigofuji/c043823d63cdfe2b02feddfa1fe8ecb0 to your computer and use it in GitHub Desktop.
Save daigofuji/c043823d63cdfe2b02feddfa1fe8ecb0 to your computer and use it in GitHub Desktop.

Projected Massachusetts town-by-town Geojson Following along with Mr. Mike Bostock's excellent post and I have to write this down or will forget…

Massachusetts Town by Town map can be found from census, as cb_2014_25_cousub_500k.zip and town data that I wanted to use is here towns.ndjson.

$ geoproject 'd3.geoConicConformal().parallels([41 + 43 / 60, 42 + 41 / 60]).rotate([71 + 30 / 60], 0).fitSize([960, 600], d)' < ma.json > ma-nad83.json

$ ndjson-join 'd.mapid' ma-mapid.ndjson towns.ndjson > ma-joined.ndjson

$ ndjson-map 'd[0].properties = {id: d[1].id, town: d[1].town, fips:d[1].fips, name:d[1].name, mapid:d[1].mapid, consubfp:d[0].properties.COUSUBFP, geoid:d[0].properties.GEOID}, d[0].id = d[1].id, d[0]' < ma-joined.ndjson >ma-joined-out.ndjson

$ ndjson-reduce < ma-joined-out.ndjson | ndjson-map '{type: "FeatureCollection", features: d}' >ma-towns.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment