Skip to content

Instantly share code, notes, and snippets.

@Mbrownshoes
Last active August 29, 2015 14:07
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 Mbrownshoes/8d0b58354d818f93f173 to your computer and use it in GitHub Desktop.
Save Mbrownshoes/8d0b58354d818f93f173 to your computer and use it in GitHub Desktop.
Canada Topojson Population by Census
.DS_Store
build
node_modules
canada.json
*.csv
.zip
T30120141007100729.CSV
build/gcsd000b11a_e.zip:
mkdir -p $(dir $@)
curl -o $@ http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/$(notdir $@)
build/gcsd000b11a_e.shp: build/gcsd000b11a_e.zip
unzip -od $(dir $@) $<
touch $@
# build/census.json: build/gcsd000b11a_e.shp
# node_modules/.bin/topojson \
# -o $@ \
# --projection='width = 960, height = 600, d3.geo.conicConformal() \
# .rotate([98, 0]) \
# .center([0, 60]) \
# .parallels([-10, 85.5]) \
# .scale(1000) \
# .translate([width / 2, height / 2]) \
# .precision(.1)' \
# --simplify=.5 \
# --filter=none \
# -- census=$<
# build/output.json: build/gcsd000b11a_e.shp T30120141007100729.CSV
# node_modules/.bin/topojson \
# -o $@ \
# --id-property='CSDUID,geo_code' \
# --external-properties=T30120141007100729.csv \
# --properties='name=CCSNAME+","+PRNAME' \
# --properties='population=+d.properties["total"]' \
# --projection='width = 960, height = 600, d3.geo.conicConformal() \
# .rotate([98, 0]) \
# .center([0, 60]) \
# .parallels([-10, 85.5]) \
# .scale(1000) \
# .translate([width / 2, height / 2]) \
# .precision(.1)' \
# --simplify=1e-8 \
# --quantization=1e5 \
# --filter=none \
# -- output=$<
build/output.json: build/gcsd000b11a_e.shp T30120141007100729.CSV
node_modules/.bin/topojson \
-o $@ \
--id-property='CSDUID,geo_code' \
--external-properties=T30120141007100729.csv \
--properties='name=CCSNAME' \
--properties='population=+d.properties["total"]' \
--projection='width = 960, height = 600, d3.geo.conicConformal() \
.rotate([98, 0]) \
.center([0, 60]) \
.parallels([-10, 85.5]) \
.scale(1000) \
.translate([width / 2, height / 2]) \
.precision(.1)' \
--simplify=1e-8 \
--quantization=1e4 \
--filter=none \
-- output=$<
build/provinces.json: build/output.json
node_modules/.bin/topojson-merge \
--o $@ \
--in-object=output \
--out-object=provinces \
--key='d.id.substring(0,2)' \
-- $<
can.json: build/provinces.json
node_modules/.bin/topojson-merge \
-o $@ \
--in-object=provinces \
--out-object=nation \
-- $<
topojson \
-o output1.json \
--id-property='CDNAME,"Geographic code"' \
--external-properties=T30120141003104421.csv \
--properties='population=+d.properties["Estimate; Total"]' \
-- build/gcsd000b11a_e.shp
** works
topojson \
-o census.json \
--id-property CSDNAME \
-- build/gcsd000b11a_e.shp
**
topojson -o ca.json -e T30120141007100729.CSV --id-property geo_code,CSDNAME -p population=+total -- build/gcsd000b11a_e.shp
topojson \
-o output.json \
-e unemployment.tsv \
--id-property=+FIPS \
-p unemployment=+rate \
-- input.shp
topojson \
-o output1.json \
--id-property='STATE+COUNTY,Id2' \
--external-properties=ACS_12_5YR_B01003_with_ann.csv \
--properties='name=Geography' \
--properties='population=+d.properties["Population"]' \
-- text.json
build/output.json: build/gcsd000b11a_e.shp T30120141003104421.csv
node_modules/.bin/topojson \
-o $@ \
--id-property='CDNAME,"Geographic code"'\
--external-properties=T30120141003104421.csv \
--properties='name=Geography' \
--properties='population=+d.properties["Estimate; Total"]'
--simplify=.5 \
--filter=none \
-- output=$<

This bubble map was inspired by Mike Bostock's Let's Make a Bubble Map.

## subdivision data
build/gcsd000b11a_e.zip:
mkdir -p $(dir $@)
curl -o $@ http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/$(notdir $@)
build/gcsd000b11a_e.shp: build/gcsd000b11a_e.zip
unzip -od $(dir $@) $<
touch $@
build/output.json: build/gcsd000b11a_e.shp T30120141007100729.CSV
node_modules/.bin/topojson \
-o $@ \
--id-property='CSDUID,geo_code' \
--external-properties=T30120141007100729.csv \
--properties='name=CCSNAME' \
--properties='population=+d.properties["total"]' \
--projection='width = 1060, height = 1100, d3.geo.conicConformal() \
.rotate([98, 0]) \
.center([10, 60]) \
.parallels([10, 85.5]) \
.scale(1400) \
.translate([width / 2, height / 2]) \
.precision(.1)' \
--simplify=1e-8 \
--quantization=1e4 \
--filter=none \
-- output=$<
provinces.json: build/output.json
node_modules/.bin/topojson-merge \
--o $@ \
--in-object=output \
--out-object=provinces \
--key='d.id.substring(0,2)' \
-- $<
can.json: build/provinces.json
node_modules/.bin/topojson-merge \
-o $@ \
--in-object=provinces \
--out-object=nation \
-- $<
## Canada
build/ne_10m_admin_0_map_subunits.shp: build/ne_10m_admin_0_map_subunits.zip
unzip -od $(dir $@) $<
touch $@
build/subunits.json: build/ne_10m_admin_0_map_subunits.shp
ogr2ogr -f GeoJSON -where "ADM0_A3 IN ('CAN')" \
build/subunits.json \
build/ne_10m_admin_0_map_subunits.shp
canada.json: build/subunits.json
node_modules/.bin/topojson \
--projection='width = 1060, height = 1100, d3.geo.conicConformal() \
.rotate([98, 0]) \
.center([10, 60]) \
.parallels([10, 85.5]) \
.scale(1400) \
.translate([width / 2, height / 2]) \
.precision(.1)' \
-o $@ \
-- $<
# ## provinces ##
# build/gpr_000b11a_e.zip:
# mkdir -p $(dir $@)
# curl -o $@ http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/$(notdir $@)
# build/gpr_000b11a_e.shp: build/gpr_000b11a_e.zip
# unzip -od $(dir $@) $<
# touch $@
# build/prov.json: build/gpr_000b11a_e.shp
# node_modules/.bin/topojson \
# -o $@ \
# --projection='width = 960, height = 600, d3.geo.conicConformal() \
# .rotate([98, 0]) \
# .center([0, 60]) \
# .parallels([-10, 85.5]) \
# .scale(1000) \
# .translate([width / 2, height / 2]) \
# .precision(.1)' \
# --simplify=100 \
# --filter=none \
# -- prov=$<
# build/canada_new.json: build/gpr_000b11a_e.json
# node_modules/.bin/topojson \
# --projection='width = 960, height = 600, d3.geo.conicConformal() \
# .rotate([98, 0]) \
# .center([0, 60]) \
# .parallels([-10, 85.5]) \
# .scale(1000) \
# .translate([width / 2, height / 2]) \
# .precision(.1)' \
# -o $@ \
# -- $<
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.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment