-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb97f37
commit 87b3323
Showing
5 changed files
with
130 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<script lang="ts"> | ||
import type { MapGeoJSONFeature } from "maplibre-gl"; | ||
import { | ||
hoveredToggle, | ||
makeColorRamp, | ||
overwriteLineLayer, | ||
overwritePmtilesSource, | ||
overwritePolygonLayer, | ||
} from "../../maplibre_helpers"; | ||
import { map } from "../../stores"; | ||
import { ExternalLink, HelpButton, InteractiveLayer } from "../common"; | ||
import { Checkbox } from "../govuk"; | ||
import { colors } from "./colors"; | ||
import SequentialLegend from "./SequentialLegend.svelte"; | ||
let name = "imd"; | ||
let outlineLayer = `${name}-outline`; | ||
let colorScale = colors.sequential_low_to_high; | ||
// The deciles are [1, 10]. The 5 colors cover two each. | ||
let limits = [0, 2, 4, 6, 8, 10]; | ||
overwritePmtilesSource( | ||
$map, | ||
name, | ||
`https://atip.uk/layers/v1/${name}.pmtiles` | ||
); | ||
overwritePolygonLayer($map, { | ||
id: name, | ||
source: name, | ||
sourceLayer: name, | ||
// Decile 1 is the most deprived, but we want to invert for the color scale | ||
color: makeColorRamp(["-", 10, ["get", "decile"]], limits, colorScale), | ||
opacity: hoveredToggle(0.5, 0.7), | ||
}); | ||
overwriteLineLayer($map, { | ||
id: outlineLayer, | ||
source: name, | ||
sourceLayer: name, | ||
color: "black", | ||
width: 0.5, | ||
}); | ||
let show = false; | ||
// InteractiveLayer manages the polygon layer, but we also need to control the outline | ||
$: { | ||
if ($map.getLayer(outlineLayer)) { | ||
$map.setLayoutProperty( | ||
outlineLayer, | ||
"visibility", | ||
show ? "visible" : "none" | ||
); | ||
} | ||
} | ||
function tooltip(feature: MapGeoJSONFeature): string { | ||
return ( | ||
`<p>${feature.properties.LSOA11CD} has an IMD score of <b>${feature.properties.score}</b></p>` + | ||
`<p>Rank: <b>${feature.properties.rank.toLocaleString()}</b> / 32,844 LSOAs</p>` | ||
); | ||
} | ||
</script> | ||
|
||
<Checkbox id={name} bind:checked={show}> | ||
Indices of Multiple Deprivation | ||
<span slot="right"> | ||
<HelpButton> | ||
<p> | ||
The 2019 English IMD scores come from <ExternalLink | ||
href="https://data-communities.opendata.arcgis.com/datasets/communities::indices-of-multiple-deprivation-imd-2019-1/explore" | ||
> | ||
DLUCH GIS | ||
</ExternalLink>. Note the LSOAs identified are from the 2011 census. A | ||
detailed breakdown of the score across different categories can be found <ExternalLink | ||
href="http://dclgapps.communities.gov.uk/imd/iod_index.html" | ||
> | ||
here | ||
</ExternalLink>. | ||
</p> | ||
<p> | ||
License: <ExternalLink | ||
href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" | ||
> | ||
Open Government License | ||
</ExternalLink>. Contains OS data © Crown copyright and database | ||
right 2023. | ||
</p> | ||
</HelpButton> | ||
</span> | ||
</Checkbox> | ||
{#if show} | ||
<SequentialLegend {colorScale} limits={["Least deprived", "Most deprived"]} /> | ||
{/if} | ||
|
||
<InteractiveLayer layer={name} {tooltip} {show} clickable={false} /> |
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