Last active
May 7, 2017 19:36
-
-
Save anisotropi4/b7fe3aea8809124619b0753558b5c27a to your computer and use it in GitHub Desktop.
Travel Time from York by Rail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Released license:gpl-3.0 | |
height:960 | |
border:no | |
Contains Ordnance Survey data © Crown copyright and database right 2012 | |
Contains National Statistics data © Crown copyright and database right 2012 | |
Travel time and geographic data is under Open Government License v3.0 http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<img src="topo.svg" width="640" height="960"> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed 's/"//g' | jq --slurp --raw-input --raw-output -c 'split("\n") | map(split(",")) | .[] | select(.[0] != null) | {CRS: .[3], (.[0]): .[1]}' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Released license:gpl-3.0 | |
height:780 | |
border:no | |
Postal Boundaries © GeoLytix copyright and database right 2012 | |
Contains Ordnance Survey data © Crown copyright and database right 2012 | |
Contains Royal Mail data © Royal Mail copyright and database right 2012 | |
Contains National Statistics data © Crown copyright and database right 2012 | |
Census data Open Government License v3.0 http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Station CRS code | |
CRS="YRK" | |
HEIGHT=960 | |
WIDTH=640 | |
PROJECTION='d3.geoConicEqualArea().parallels([49, 61]).fitSize(['${WIDTH}','${HEIGHT}'], d)' | |
SCALE="d3.bisect([30, 60, 90, 120, 150, 180, 210, 240, 270, 300],d.properties.time)" | |
FILL="d3.schemeSpectral[11][d.properties.scale]" | |
if [ ! -f Rail-stations-travel-times.zip ] | |
then | |
wget http://data.dft.gov.uk.s3.amazonaws.com/connectivity-data/Rail-stations-travel-times.zip | |
fi | |
if [ ! -f Stations_HW_AM.csv ] | |
then | |
unzip Rail-stations-travel-times.zip Stations_HW_AM.csv | |
fi | |
if [ ! -f Stations_HW_AM.ndjson ] | |
then | |
tail -n +2 Stations_HW_AM.csv | \ | |
split -l 262144 --filter=./jq-script.sh | \ | |
sort | \ | |
split -l 8192 --filter="jq -c -s 'group_by(.CRS) | .[] | add'" | \ | |
jq -c -s 'group_by(.CRS) | .[] | add' > Stations_HW_AM.ndjson | |
fi | |
if [ ! -f 90e15daaaeef4baa877f4bffe01ebef0_2.zip ] | |
then | |
wget http://geoportal.statistics.gov.uk/datasets/90e15daaaeef4baa877f4bffe01ebef0_2.zip | |
fi | |
if [ ! -s LLSOA-2001-England-and-Wales.ndjson ] | |
then | |
unzip 90e15daaaeef4baa877f4bffe01ebef0_2.zip | |
for i in *2001*.shp | |
do | |
ogr2ogr -t_srs EPSG:4326 -f GeoJSON /vsistdout/ ${i} | \ | |
jq -c '.features[] | ({ id: .properties.lsoa01cd} + . )' | \ | |
geo2topo -n tracts=- | toposimplify -s 2.5E-10 -F | \ | |
topo2geo -n tracts=- | |
done > LLSOA-2001-England-and-Wales.ndjson | |
fi | |
if [ ! -s topo.json ] | |
then | |
geo2topo -n tracts=<(ndjson-join 'd.id' \ | |
<(jq -c 'select(.CRS=="'${CRS}'") | del(.CRS) | to_entries | map({id: .key, time: .value})[]' Stations_HW_AM.ndjson) \ | |
<(jq -s -c '{"type": "FeatureCollection", "features": .}' LLSOA-2001-England-and-Wales.ndjson | \ | |
geoproject "${PROJECTION}" | \ | |
jq -c '.features[]') | \ | |
ndjson-map -r d3 '{type: d[1].type, properties: {title: d[0].id, time: d[0].time}, geometry: d[1].geometry}') | \ | |
toposimplify -p 1 -f | \ | |
topoquantize 1E6 > topo.json | |
fi | |
< topo.json topo2geo -n tracts=- | \ | |
ndjson-map -r d3=d3 '(d.properties.scale='"${SCALE}"',d)' | \ | |
ndjson-map -r d3=d3-scale-chromatic '(d.properties.fill='"${FILL}"', d)' | \ | |
geo2svg --stroke=none -n -p 1 -w ${WIDTH} -h ${HEIGHT} | \ | |
sed '$d' > topo.svg | |
# Insert the legend. | |
tail -n +4 \ | |
< legend.svg \ | |
>> topo.svg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment