Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Ready-to-use map files for the Power BI **Shape map** visual: real boundaries an
[![Deploy site](https://github.com/CodeWithBehnam/map-powerbi/actions/workflows/pages.yml/badge.svg)](https://github.com/CodeWithBehnam/map-powerbi/actions/workflows/pages.yml)
[![Dashboard: live](https://img.shields.io/badge/dashboard-live-2a78d6)](https://codewithbehnam.github.io/map-powerbi/)
[![Power BI: Shape map](https://img.shields.io/badge/Power%20BI-Shape%20map-F2C811)](docs/power-bi-guide.md)
[![Map files: 174](https://img.shields.io/badge/map%20files-174-informational)](docs/map-files.md)
[![Map files: 180](https://img.shields.io/badge/map%20files-180-informational)](docs/map-files.md)
[![Licence: MIT](https://img.shields.io/badge/licence-MIT-blue)](LICENSE)
[![Data: OGL v3.0](https://img.shields.io/badge/data-OGL%20v3.0-brightgreen)](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/)

Expand Down Expand Up @@ -62,7 +62,7 @@ Files follow one pattern:
maps/<version>/<level>/<area>/<map type>/<file>.json
```

The **[catalogue](docs/map-files.md)** lists all 174 files with links and shape counts. This table shows what exists.
The **[catalogue](docs/map-files.md)** lists all 180 files with links and shape counts. This table shows what exists.

| Shapes | Areas covered | Versions | Shapes per file |
|---|---|---|---|
Expand All @@ -74,6 +74,7 @@ The **[catalogue](docs/map-files.md)** lists all 174 files with links and shape
| Councils | Northern Ireland | 2021, 2026 | 11 |
| Health boards | Wales | 2023 | 7 |
| Primary care clusters | Wales | 2019, 2024 | 64 and 63 |
| Primary care clusters | Swansea Bay health board area | 2019, 2024 | 8 |

**The all-Wales LSOA file has 1,917 shapes, more than the 1,500 that Power BI plots.** For LSOA maps in Power BI, use a health board file instead. Every other file fits.

Expand Down
9 changes: 8 additions & 1 deletion docs/map-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- Generated by `bun run catalogue`. Do not edit by hand. -->

Every map file in this repository: 174 files. Each link opens the file on GitHub, where **Download raw file** saves it.
Every map file in this repository: 180 files. Each link opens the file on GitHub, where **Download raw file** saves it.

- **Shapes** is the number of areas in the file. Power BI's Shape map plots at most 1,500.
- Every map has a preview image at the same path under [`images/`](../images), ending in `.svg`.
Expand Down Expand Up @@ -108,6 +108,13 @@ Every map file in this repository: 174 files. Each link opens the file on GitHub
| Cluster | 2019 | Wales | 64 | [geographic](../maps/2019/cluster/wales/geographic/wales-cluster-2019.json) | [hexmap](../maps/2019/cluster/wales/hexmap/wales-cluster-2019-hexmap.json) | [geogrid](../maps/2019/cluster/wales/geogrid/wales-cluster-2019-geogrid.json) | [CSV](../data/synthetic/synthetic-cluster-2019.csv) |
| Cluster | 2024 | Wales | 63 | [geographic](../maps/2024/cluster/wales/geographic/wales-cluster-2024.json) | [hexmap](../maps/2024/cluster/wales/hexmap/wales-cluster-2024-hexmap.json) | [geogrid](../maps/2024/cluster/wales/geogrid/wales-cluster-2024-geogrid.json) | [CSV](../data/synthetic/synthetic-cluster-2024.csv) |

## Swansea Bay primary care clusters

| Level | Version | Area | Shapes | Geographic | Hexmap | Geogrid | Sample data |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Cluster | 2019 | Swansea Bay health board area | 8 | [geographic](../maps/2019/cluster/swansea-bay/geographic/swansea-bay-cluster-2019.json) | [hexmap](../maps/2019/cluster/swansea-bay/hexmap/swansea-bay-cluster-2019-hexmap.json) | [geogrid](../maps/2019/cluster/swansea-bay/geogrid/swansea-bay-cluster-2019-geogrid.json) | [CSV](../data/synthetic/synthetic-cluster-2019.csv) |
| Cluster | 2024 | Swansea Bay health board area | 8 | [geographic](../maps/2024/cluster/swansea-bay/geographic/swansea-bay-cluster-2024.json) | [hexmap](../maps/2024/cluster/swansea-bay/hexmap/swansea-bay-cluster-2024-hexmap.json) | [geogrid](../maps/2024/cluster/swansea-bay/geogrid/swansea-bay-cluster-2024-geogrid.json) | [CSV](../data/synthetic/synthetic-cluster-2024.csv) |

## Where the boundaries come from

| Level | Version | Publisher | Layer |
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"Topology","arcs":[[[214,232],[71,38]],[[285,270],[71,-38]],[[356,232],[0,-77]],[[356,155],[-71,-39]],[[285,116],[-71,39]],[[214,155],[0,77]],[[142,116],[0,-77]],[[142,39],[-71,-39],[-71,39],[0,77],[71,39],[71,-39]],[[285,348],[0,-78]],[[214,232],[-72,38],[0,78],[72,38],[71,-38]],[[142,116],[72,39]],[[285,116],[0,-77],[-71,-39],[-72,39]],[[285,348],[71,38],[71,-38]],[[427,348],[0,-78]],[[427,270],[-71,-38]],[[427,270],[72,-38]],[[499,232],[0,-77]],[[499,155],[-72,-39],[-71,39]],[[499,232],[71,38]],[[570,270],[71,-38],[0,-77],[-71,-39],[-71,39]],[[427,348],[72,38],[71,-38],[0,-78]]],"transform":{"scale":[0.0011001700468018713,0.0007266632124352393],"translate":[-4.236336,51.54199199999999]},"objects":{"cluster_2019":{"type":"GeometryCollection","geometries":[{"arcs":[[0,1,2,3,4,5]],"type":"Polygon","properties":{"CLUSTERCD":"CC306","CLUSTERNM":"CityHealth"},"id":"CC306"},{"arcs":[[6,7]],"type":"Polygon","properties":{"CLUSTERCD":"CC302","CLUSTERNM":"BayHealth"},"id":"CC302"},{"arcs":[[8,-1,9]],"type":"Polygon","properties":{"CLUSTERCD":"CC308","CLUSTERNM":"Llwchwr"},"id":"CC308"},{"arcs":[[10,-5,11,-7]],"type":"Polygon","properties":{"CLUSTERCD":"CC310","CLUSTERNM":"Penderi"},"id":"CC310"},{"arcs":[[12,13,14,-2,-9]],"type":"Polygon","properties":{"CLUSTERCD":"CC307","CLUSTERNM":"Cwmtawe"},"id":"CC307"},{"arcs":[[-15,15,16,17,-3]],"type":"Polygon","properties":{"CLUSTERCD":"CC309","CLUSTERNM":"Neath"},"id":"CC309"},{"arcs":[[18,19,-17]],"type":"Polygon","properties":{"CLUSTERCD":"CC301","CLUSTERNM":"Afan"},"id":"CC301"},{"arcs":[[20,-19,-16,-14]],"type":"Polygon","properties":{"CLUSTERCD":"CC311","CLUSTERNM":"Upper Valleys"},"id":"CC311"}]}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"Topology","arcs":[[[303,38],[0,76]],[[303,114],[76,38]],[[379,152],[68,-34]],[[447,118],[0,-84],[-68,-34],[-76,38]],[[152,114],[0,-76]],[[152,38],[-76,-38],[-76,38],[0,76],[76,38],[76,-38]],[[227,152],[0,76],[76,38],[76,-38]],[[379,228],[0,-76]],[[303,114],[-76,38]],[[152,114],[75,38]],[[303,38],[-76,-38],[-75,38]],[[379,228],[76,38],[68,-35],[0,-75],[-76,-38]],[[538,148],[0,83],[68,35]],[[606,266],[76,-38]],[[682,228],[0,-76],[-76,-38]],[[606,114],[-68,34]],[[606,114],[0,-76],[-75,-38],[-69,34],[0,76],[76,38]],[[606,266],[0,75],[76,38],[76,-38],[0,-75],[-76,-38]]],"transform":{"scale":[0.00109935092348285,0.0007862849604221739],"translate":[-4.289176,51.57815099999999]},"objects":{"cluster_2019":{"type":"GeometryCollection","geometries":[{"arcs":[[0,1,2,3]],"type":"Polygon","properties":{"CLUSTERCD":"CC306","CLUSTERNM":"CityHealth"},"id":"CC306"},{"arcs":[[4,5]],"type":"Polygon","properties":{"CLUSTERCD":"CC302","CLUSTERNM":"BayHealth"},"id":"CC302"},{"arcs":[[6,7,-2,8]],"type":"Polygon","properties":{"CLUSTERCD":"CC308","CLUSTERNM":"Llwchwr"},"id":"CC308"},{"arcs":[[-5,9,-9,-1,10]],"type":"Polygon","properties":{"CLUSTERCD":"CC310","CLUSTERNM":"Penderi"},"id":"CC310"},{"arcs":[[-8,11,-3]],"type":"Polygon","properties":{"CLUSTERCD":"CC307","CLUSTERNM":"Cwmtawe"},"id":"CC307"},{"arcs":[[12,13,14,15]],"type":"Polygon","properties":{"CLUSTERCD":"CC309","CLUSTERNM":"Neath"},"id":"CC309"},{"arcs":[[-16,16]],"type":"Polygon","properties":{"CLUSTERCD":"CC301","CLUSTERNM":"Afan"},"id":"CC301"},{"arcs":[[17,-14]],"type":"Polygon","properties":{"CLUSTERCD":"CC311","CLUSTERNM":"Upper Valleys"},"id":"CC311"}]}}}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"Topology","arcs":[[[285,348],[0,-78]],[[285,270],[-71,-38]],[[214,232],[-72,38],[0,78],[72,38],[71,-38]],[[142,116],[0,-77]],[[142,39],[-71,-39],[-71,39],[0,77],[71,39],[71,-39]],[[285,270],[71,-38]],[[356,232],[0,-77]],[[356,155],[-71,-39]],[[285,116],[-71,39]],[[214,155],[0,77]],[[285,348],[71,38],[71,-38]],[[427,348],[0,-78]],[[427,270],[-71,-38]],[[142,116],[72,39]],[[285,116],[0,-77],[-71,-39],[-72,39]],[[427,348],[72,38],[71,-38],[0,-78]],[[570,270],[-71,-38]],[[499,232],[-72,38]],[[570,270],[71,-38],[0,-77],[-71,-39],[-71,39]],[[499,155],[0,77]],[[499,155],[-72,-39],[-71,39]]],"transform":{"scale":[0.0011001606864274565,0.0007266554404144967],"translate":[-4.23633,51.541994]},"objects":{"cluster_2024":{"type":"GeometryCollection","geometries":[{"arcs":[[0,1,2]],"type":"Polygon","properties":{"CLUSTERCD":"CC308","CLUSTERNM":"Llwchwr","CLUSTERNMW":"Llwchwr"},"id":"CC308"},{"arcs":[[3,4]],"type":"Polygon","properties":{"CLUSTERCD":"CC302","CLUSTERNM":"BayHealth","CLUSTERNMW":"Iechyd y Bae"},"id":"CC302"},{"arcs":[[-2,5,6,7,8,9]],"type":"Polygon","properties":{"CLUSTERCD":"CC306","CLUSTERNM":"CityHealth","CLUSTERNMW":"Iechyd y Ddinas"},"id":"CC306"},{"arcs":[[10,11,12,-6,-1]],"type":"Polygon","properties":{"CLUSTERCD":"CC307","CLUSTERNM":"Cwmtawe","CLUSTERNMW":"Cwmtawe"},"id":"CC307"},{"arcs":[[13,-9,14,-4]],"type":"Polygon","properties":{"CLUSTERCD":"CC310","CLUSTERNM":"Penderi","CLUSTERNMW":"Penderi"},"id":"CC310"},{"arcs":[[15,16,17,-12]],"type":"Polygon","properties":{"CLUSTERCD":"CC311","CLUSTERNM":"Upper Valleys","CLUSTERNMW":"Blaenau'r Cymoedd"},"id":"CC311"},{"arcs":[[-17,18,19]],"type":"Polygon","properties":{"CLUSTERCD":"CC301","CLUSTERNM":"Afan","CLUSTERNMW":"Afan"},"id":"CC301"},{"arcs":[[-13,-18,-20,20,-7]],"type":"Polygon","properties":{"CLUSTERCD":"CC309","CLUSTERNM":"Neath","CLUSTERNMW":"Castell-nedd"},"id":"CC309"}]}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"Topology","arcs":[[[80,260],[0,73],[80,37],[80,-37]],[[240,333],[0,-73]],[[240,260],[-80,-37]],[[160,223],[-80,37]],[[160,223],[0,-75]],[[160,148],[-80,-37]],[[80,111],[-80,37],[0,75],[80,37]],[[160,148],[80,-37]],[[240,111],[0,-74],[-80,-37],[-80,37],[0,74]],[[240,333],[80,37],[72,-33],[0,-74],[-80,-37]],[[312,226],[-72,34]],[[312,226],[0,-81],[-72,-34]],[[480,370],[0,74],[80,37],[80,-37],[0,-74],[-80,-37]],[[560,333],[-80,37]],[[408,256],[72,-33]],[[480,223],[0,-75],[-80,-37],[-72,34],[0,74],[80,37]],[[408,256],[0,81],[72,33]],[[560,333],[0,-73],[-80,-37]]],"transform":{"scale":[0.0010303062500000009,0.0007974241164241169],"translate":[-4.123452,51.491383]},"objects":{"cluster_2024":{"type":"GeometryCollection","geometries":[{"arcs":[[0,1,2,3]],"type":"Polygon","properties":{"CLUSTERCD":"CC308","CLUSTERNM":"Llwchwr","CLUSTERNMW":"Llwchwr"},"id":"CC308"},{"arcs":[[-4,4,5,6]],"type":"Polygon","properties":{"CLUSTERCD":"CC302","CLUSTERNM":"BayHealth","CLUSTERNMW":"Iechyd y Bae"},"id":"CC302"},{"arcs":[[-6,7,8]],"type":"Polygon","properties":{"CLUSTERCD":"CC306","CLUSTERNM":"CityHealth","CLUSTERNMW":"Iechyd y Ddinas"},"id":"CC306"},{"arcs":[[-2,9,10]],"type":"Polygon","properties":{"CLUSTERCD":"CC307","CLUSTERNM":"Cwmtawe","CLUSTERNMW":"Cwmtawe"},"id":"CC307"},{"arcs":[[-5,-3,-11,11,-8]],"type":"Polygon","properties":{"CLUSTERCD":"CC310","CLUSTERNM":"Penderi","CLUSTERNMW":"Penderi"},"id":"CC310"},{"arcs":[[12,13]],"type":"Polygon","properties":{"CLUSTERCD":"CC311","CLUSTERNM":"Upper Valleys","CLUSTERNMW":"Blaenau'r Cymoedd"},"id":"CC311"},{"arcs":[[14,15]],"type":"Polygon","properties":{"CLUSTERCD":"CC301","CLUSTERNM":"Afan","CLUSTERNMW":"Afan"},"id":"CC301"},{"arcs":[[16,-14,17,-15]],"type":"Polygon","properties":{"CLUSTERCD":"CC309","CLUSTERNM":"Neath","CLUSTERNMW":"Castell-nedd"},"id":"CC309"}]}}}
25 changes: 25 additions & 0 deletions scripts/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const selectorKey = (selector: Selector): string => {
return selector.council.slug;
case "codePrefix":
return `prefix-${selector.prefix}`;
case "codes":
return `codes-${selector.codes.join("-")}`;
case "all":
return "all";
}
Expand All @@ -49,6 +51,8 @@ const whereClause = (source: Source, selector: Selector): string => {
return "1=1";
case "codePrefix":
return `${layerField(source, source.codeField)} LIKE '${selector.prefix}%'`;
case "codes":
return `${layerField(source, source.codeField)} IN (${selector.codes.map((code) => `'${code}'`).join(", ")})`;
case "council": {
const { council } = selector;
if (source.filter === undefined) {
Expand Down Expand Up @@ -182,12 +186,33 @@ const cachePath = (source: Source, selector: Selector): string =>

const loads = new Map<string, Promise<readonly Feature[]>>();

// DataMapWales layers are only downloaded whole, so picking by code filters that download.
const pickCodes = async (
source: Source,
selector: Extract<Selector, { kind: "codes" }>,
refresh: boolean,
): Promise<readonly Feature[]> => {
const all = await loadSelector(source, { kind: "all", label: selector.label }, refresh);
const picked = all.filter((feature) =>
selector.codes.includes(String(feature.properties[source.codeField])),
);
if (picked.length !== selector.codes.length) {
throw new Error(
`${source.service}: found ${picked.length} of the ${selector.codes.length} codes ${selector.codes.join(", ")}`,
);
}
return picked;
};

/** The areas of one selector, with only the configured fields. Cached on disk and in memory. */
export const loadSelector = (
source: Source,
selector: Selector,
refresh: boolean,
): Promise<readonly Feature[]> => {
if (source.provider === "datamapwales" && selector.kind === "codes") {
return pickCodes(source, selector, refresh);
}
const path = cachePath(source, selector);
const running = loads.get(path);
if (running !== undefined) {
Expand Down
Loading
Loading