Adham Enaya
Adham Enaya

Reputation: 908

Problem while displaying Choropleth map for UK using Altair

I am downloading dataset from two different sources for UK areas. And I am using Altair code to display a Choropleth Map. But this what I get for both datasets using the following code:

_map = alt.Chart(geo_uk, title='UK Map').mark_geoshape().encode().properties(width=500,height=300);

Link to used data source (GeoJson file) enter image description here

Upvotes: 0

Views: 248

Answers (1)

r-beginners
r-beginners

Reputation: 35135

I don't use altair all the time, so I don't know if my answer is satisfactory to you. I created a map with the information available from the given geojson file. My answer is based on this answer. If the map is not the one you intend, you may need to convert it in the world geodetic system.

import altair as alt
import json

file = './data/Local_Authority_Districts__April_2019__UK_BGC_v2.geojson'
with open(file) as f:
    data_json = json.load(f) 

geo_uk = alt.Data(values=data_json, format=alt.DataFormat(property='features',type='json'))

_map = alt.Chart(geo_uk, title='UK Map').mark_geoshape(
).encode(
    color="properties.LAD19NM:N"
).project(
    type='identity', reflectY=True
).properties(width=800,height=600)
_map

enter image description here

Upvotes: 2

Related Questions