-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start another zone-to-point example. #27
- Loading branch information
1 parent
28ec65a
commit ab9a7a4
Showing
5 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"requests": { | ||
"Generate": { | ||
"pattern": { | ||
"ZoneToPoint": { | ||
"zones_path": "zones.geojson", | ||
"destinations_path": "destinations.geojson", | ||
"csv_path": "od.csv" | ||
} | ||
} | ||
} | ||
}, | ||
"routing": { | ||
"FastPaths": { | ||
"cost": "Distance" | ||
} | ||
}, | ||
"uptake": "Identity", | ||
"lts": "BikeOttawa" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"name": "hospital" | ||
}, | ||
"geometry": { | ||
"coordinates": [ | ||
-2.897064035677346, | ||
53.41852905901993 | ||
], | ||
"type": "Point" | ||
} | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import csv | ||
import json | ||
import sys | ||
|
||
sys.path.append("..") | ||
|
||
from utils import * | ||
|
||
run(["mkdir", "-p", "input"]) | ||
|
||
download( | ||
url="https://download.geofabrik.de/europe/great-britain/england/merseyside-latest.osm.pbf", | ||
outputFilename="input/input.osm.pbf", | ||
) | ||
|
||
extractCentroids(pbfInput="input/input.osm.pbf", geojsonOutput="input/origins.geojson") | ||
|
||
# You have to manually download the Geopackage from https://geoportal.statistics.gov.uk/datasets/ons::output-areas-dec-2011-boundaries-ew-bgc/explore and put Output_Areas_Dec_2011_Boundaries_EW_BGC_2022_7971430631129549274.gpkg in input/ | ||
|
||
# First convert the CRS | ||
run( | ||
[ | ||
"ogr2ogr" "-f", | ||
"GeoJSON", | ||
"input/all_oas.geojson", | ||
"input/Output_Areas_Dec_2011_Boundaries_EW_BGC_2022_7971430631129549274.gpkg", | ||
"-t_srs", | ||
"EPSG:4326", | ||
] | ||
) | ||
# Then clip (thanks to bboxfinder.com) | ||
run( | ||
[ | ||
"ogr2ogr", | ||
"-f", | ||
"GeoJSON", | ||
"input/clipped_oas.geojson", | ||
"-clipsrc", | ||
"-3.290405", | ||
"53.291900", | ||
"-2.532349", | ||
"53.512960", | ||
"input/all_oas.geojson", | ||
] | ||
) | ||
|
||
# Then manually fix properties | ||
with open("input/clipped_oas.geojson") as f1: | ||
gj = json.load(f1) | ||
for f in gj["features"]: | ||
props = {"name": f["properties"]["OA11CD"]} | ||
f["properties"] = props | ||
|
||
with open("input/zones.geojson", "w") as f2: | ||
f2.write(json.dumps(gj)) | ||
|
||
|
||
# To figure out the WPZ containing Alder Hey Hospital, go to https://geoportal.statistics.gov.uk/datasets/ons::workplace-zones-december-2011-full-clipped-boundaries-in-england-and-wales-1/explore, find the hospital by zooming in or using search, then copy the wz11cd property. | ||
target_wpz = "E33003019" | ||
|
||
# You have to manually download WF01AEW_oa from https://wicid.ukdataservice.ac.uk/flowdata/cider/wicid/downloads.php, unzip, and put wf01aew_oa_v1.csv in input/ | ||
# TODO Or in-place | ||
with open("input/wf01aew_oa_v1.csv") as f1: | ||
with open("input/od.csv", "w") as f2: | ||
writer = csv.DictWriter(f2, fieldnames=["from", "to", "count"]) | ||
writer.writeheader() | ||
|
||
for row in csv.reader(f1): | ||
if row[1] != target_wpz: | ||
continue | ||
|
||
writer.writerow( | ||
{ | ||
"from": row[0], | ||
"to": "hospital", | ||
# This dataset doesn't break down by mode | ||
"count": int(row[2]), | ||
} | ||
) |