Skip to content

Instantly share code, notes, and snippets.

@johnjreiser
Last active February 5, 2023 20:14
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 johnjreiser/57394932506541f772e0b6d53c56565a to your computer and use it in GitHub Desktop.
Save johnjreiser/57394932506541f772e0b6d53c56565a to your computer and use it in GitHub Desktop.
New Jersey counties in TopoJSON
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
# get us topojson file
curl -o us.topojson https://gist.githubusercontent.com/cmdoptesc/4714c586f69425043ae3/raw/d534aba169207548a8a3d670c9c2cc719ff05c47/us.json
# extract NJ counties to GeoJSON
ogr2ogr -f GeoJSON nj.geojson us.topojson counties -where "id like '34%'" -lco COORDINATE_PRECISION=7
# install topojson-server (if not already installed)
npm install topojson-server
# convert the GeoJSON to TopoJSON
npx geo2topo nj.geojson > nj.topojson
# make pretty if desired (using https://stedolan.github.io/jq/)
jq . nj.topojson > nj.topojson.pretty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment