Reputation: 23
I'm trying to show regions within the UK from the following geojson file: https://data.nationalgrideso.com/system/gis-boundaries-for-gb-dno-license-areas
However I can't seem to get any results displayed, besides the scale and mapbox frame. Here's my test code below:
import os, json
import numpy as np
import pandas as pd
import plotly.express as px
#dataframe
d = {'Value': np.random.randint(1000,size=14),
'geojson_id':[17,22,21,12,19,10,20,18,13,16,15,23,11,14]}
df= pd.DataFrame(data=d)
#geojson file
basedir = os.path.abspath(os.path.dirname(__file__))
filename= os.path.join(basedir, 'dno_license_areas_20200506.geojson')
with open(filename) as response:
dno_zones = json.load(response)
#Choropleth PLOT
fig = px.choropleth_mapbox(df, geojson=dno_zones,color='Value',
locations='geojson_id', featureidkey="properties.ID",
center={"lat": 54.3, "lon": 0.0},
mapbox_style="carto-positron", zoom=4)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
What am I missing ?
Upvotes: 0
Views: 800
Reputation: 31146
<Derived Projected CRS: EPSG:27700>
Name: OSGB36 / British National Grid
Axis Info [cartesian]:
- E[east]: Easting (metre)
- N[north]: Northing (metre)
Area of Use:
- name: United Kingdom (UK) - offshore to boundary of UKCS within 49°45'N to 61°N and 9°W to 2°E; onshore Great Britain (England, Wales and Scotland). Isle of Man onshore.
- bounds: (-9.0, 49.75, 2.01, 61.01)
Coordinate Operation:
- name: British National Grid
- method: Transverse Mercator
Datum: Ordnance Survey of Great Britain 1936
- Ellipsoid: Airy 1830
- Prime Meridian: Greenwich
import os, json, requests
import numpy as np
import pandas as pd
import plotly.express as px
import geopandas as gpd
# dataframe
d = {
"Value": np.random.randint(1000, size=14),
"geojson_id": [17, 22, 21, 12, 19, 10, 20, 18, 13, 16, 15, 23, 11, 14],
}
df = pd.DataFrame(data=d)
# #geojson file
# basedir = os.path.abspath(os.path.dirname(__file__))
# filename= os.path.join(basedir, 'dno_license_areas_20200506.geojson')
# with open(filename) as response:
# dno_zones = json.load(response)
dno_zones = requests.get(
"https://data.nationalgrideso.com/backend/dataset/0e377f16-95e9-4c15-a1fc-49e06a39cfa0/resource/e96db306-aaa8-45be-aecd-65b34d38923a/download/dno_license_areas_20200506.geojson"
).json()
dno_zones = (
gpd.GeoDataFrame.from_features(
dno_zones, crs=dno_zones["crs"]["properties"]["name"]
)
.to_crs("epsg:4326")
.__geo_interface__
)
# Choropleth PLOT
fig = px.choropleth_mapbox(
df,
geojson=dno_zones,
color="Value",
locations="geojson_id",
featureidkey="properties.ID",
center={"lat": 54.3, "lon": 0.0},
mapbox_style="carto-positron",
zoom=4,
)
fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})
fig.show()
Upvotes: 3