-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic population layer from popgetter #10
Changes from 4 commits
f3702bd
0468a91
80d45f1
71f2fb9
741da3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.geojson |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/bash | ||
# This script prepares a consolidated FGB file with total population count in | ||
# the most granular zone for different countries, using | ||
# https://github.com/Urban-Analytics-Technology-Platform/popgetter. This script | ||
# / process might live elsewhere at some point. | ||
|
||
set -e | ||
set -x | ||
|
||
# You need to build https://github.com/Urban-Analytics-Technology-Platform/popgetter-cli | ||
POPGETTER=/home/dabreegster/Downloads/popgetter-cli/target/release/popgetter | ||
|
||
# The metrics and coordinate systems were figured out manually. In the future, | ||
# this'll be easier with a popgetter web UI. | ||
|
||
# England | ||
$POPGETTER data \ | ||
--force-run \ | ||
--output-format geojson \ | ||
--output-file england_raw.geojson \ | ||
--geometry-level oa \ | ||
--id 1355501cf6f3b1fa8cf6a100c98f330d51a3382ed2111fef0d2fff446608a428 | ||
mapshaper england_raw.geojson \ | ||
-rename-fields population='Residence type: Total; measures: Value' \ | ||
-each 'delete GEO_ID' \ | ||
-proj init=EPSG:27700 crs=wgs84 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be useful to have a column in the geometry parquet file with this. I found https://github.com/Urban-Analytics-Technology-Platform/popgetter-cli/blob/c4da85910e317b654ac4c5aa9a6de09abb985e1f/src/cli.rs#L61 as the only reference right now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, thanks for mentioning, there is an issue https://github.com/Urban-Analytics-Technology-Platform/popgetter/issues/142 discussing this further and I've added it to the list of potential changes https://github.com/Urban-Analytics-Technology-Platform/popgetter/issues/149 |
||
-o england.geojson | ||
|
||
# Belgium | ||
$POPGETTER data \ | ||
--force-run \ | ||
--output-format geojson \ | ||
--output-file belgium_raw.geojson \ | ||
--geometry-level statistical_sector \ | ||
--id fcf09809889c1d9715bff5f825b0c6ed4d9286f2e2b4948839accc29c15e98c5 | ||
mapshaper belgium_raw.geojson \ | ||
-rename-fields population='TOTAL' \ | ||
-each 'delete GEO_ID' \ | ||
-proj init=EPSG:3812 crs=wgs84 \ | ||
-o belgium.geojson | ||
|
||
# USA | ||
# TODO This might not be the right variable, and it's only at block_group | ||
$POPGETTER data \ | ||
--force-run \ | ||
--output-format geojson \ | ||
--output-file usa_raw.geojson \ | ||
--geometry-level block_group \ | ||
--id d23e348af6ab03265b4f258178edc6b509651095f81b965c1a62396fe463d0f6 | ||
mapshaper usa_raw.geojson \ | ||
-rename-fields population='B01001_E001' \ | ||
-each 'delete GEO_ID' \ | ||
-o usa.geojson | ||
|
||
# Scotland | ||
# TODO | ||
|
||
# Northern Ireland | ||
# TODO | ||
|
||
# Merge files. You need to build https://github.com/acteng/will-it-fit/tree/main/data_prep/merge_files | ||
MERGER=/home/dabreegster/will-it-fit/data_prep/merge_files/target/release/merge_files | ||
$MERGER england.geojson belgium.geojson usa.geojson | ||
# Hosting: mv out.fgb ~/cloudflare_sync/population.fgb, sync it |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script lang="ts"> | ||
import { GeoJSON, LineLayer, FillLayer, hoverStateFilter } from "svelte-maplibre"; | ||
import { notNull } from "svelte-utils"; | ||
import { Popup } from "svelte-utils/map"; | ||
import { backend } from "../stores"; | ||
</script> | ||
|
||
{#await notNull($backend).renderZones() then data} | ||
<GeoJSON {data} generateId> | ||
<FillLayer | ||
manageHoverState | ||
paint={{ | ||
"fill-color": "red", | ||
"fill-opacity": hoverStateFilter(0.5, 0.8), | ||
}} | ||
> | ||
<Popup openOn="hover" let:props>{props.population.toLocaleString()}</Popup | ||
> | ||
</FillLayer> | ||
<LineLayer paint={{"line-color": "black", "line-width": 1}} /> | ||
</GeoJSON> | ||
{/await} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wound up doing very ad-hoc things to figure out the most recent and granular "total population" metric (and am probably wrong for the US): googling, navigating the UK census page, opening the metrics parquet file and manually searching, etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really helpful to hear the search process you went through, thank you!
Adding some info here for context, for each country in popgetter currently there are:
I think the derived metrics in case 2) need to be more easily discoverable so readily accessible for common use cases (such as "Total individuals" here). The ones transformed in 1) should also be made more easy to find using e.g. the original census table name/metric name, the variables that were in the original metric/table, etc.
I'll add the option of listing only the "derived metrics" from the CLI to the ideas issue (Urban-Analytics-Technology-Platform/popgetter#81) while enabling metrics of type 1) to be discoverable at least requires adding some data currently missing for
source_metric_id
(https://github.com/Urban-Analytics-Technology-Platform/popgetter/issues/149)