import geopandas
import topojson
import matplotlib.pyplot as plt
from IPython.display import display_markdown
display_markdown(open("README.md").read(), raw=True)
This dataset contains results for the Brexit vote at the local authority district, and administrative boundaries.
brexit_vote.csv
¶Source
: Electoral CommissionURL
http://www.electoralcommission.org.uk/__data/assets/file/0014/212135/EU-referendum-result-data.csv
Processing
: no processing was required for this dataset, see original source for additional informationSource
: Office for National StatisticsURL
Processing
: no processing was required for this dataset, see original source for additional informationThe original geometries are downloaded from the Office of National Statistics through data.gov.uk
and stored locally:
lads = geopandas.read_file('./Local_Authority_Districts_December_2016_'
'Generalised_Clipped_Boundaries_in_the_UK_WGS84/'
'Local_Authority_Districts_December_2016_'
'Generalised_Clipped_Boundaries_in_the_UK_WGS84.shp'
)
To obtain a much more lightweight set of geometries, we simplify the layer, respecting its topology. First we build the topology:
topology = topojson.Topology(lads)
Then simplify it:
simple_uk = topology.toposimplify(.025)
Inspect the resulting geography:
simple_uk.to_gdf().plot()
<AxesSubplot:>
And we can write it to a GeoJSON file:
simple_uk.to_gdf().to_file('./local_authority_districts.geojson', driver="GeoJSON")
[Download the simplified LAD geometries as a GeoJSON] <local_authority_districts.geojson>
[Download the EU referendum vote results as a CSV] <brexit_vote.csv>