SylwiaOliwia2 / uk-photovoltaics-map

Daily pull UK solar panels data and visualise them using Mapbox & Leaflet.

Home Page:https://sylwia.hs3.linux.pl/my_files/uk_photovoltaics_map/frontend/mapbox_uk.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

uk-postcode-map

UK_MAP

The map shows how many percent of "feed-in tariff" (FIT) panels was put on the Open Street Map (OSM) for UK. It was initially created for OpenClimateFix contributors to indicate which postcode districts lack information about solar panels location. The code (Python 3.5) enable also to update the amount of panels in the UK to display.

The map is beeing updated daily and can be found HERE.

How to use

Docker

Build the image (at first navigate the folder above the docker folder, ex. uk-postcode-map): docker build -t uk_postcode_map -f docker/Dockerfile .

Get the newest data form OSM about the amount of solar panels in the UK postcode areas: sudo docker run --name uk_postcode_map -it uk_postcode_map

Display the map:

  1. Copy the map folder from the container (it will create the new folder uk_postcode_map_frontend in the current folder):sudo docker cp uk_postcode_map:/docker/frontend uk_postcode_map_frontend
  2. Display the map (you can replace firefox with another browser) firefox uk_postcode_map_frontend/frontend/mapbox_uk.html

Local

Clone the repository and run in the console python setup.py install.

To see the map, open the frontend/mapbox_uk.html file in the browser.

To get the newest data form OSM about the amount of solar panels in the UK postcode areas, type in the consolepython data_preprocessing/calculate_stats_for_postcodes.py. The script will at first retrive coordinates for each solar panel in the UK added to OSM. Then, for each panels coordinates, the postcode is retrived. The final data will be saved in frontend/postcodes_updated.js. The intermediate files (containing raw query results) will be saved in data_preprocessing/data.

The optional parameters for calculate_stats_for_postcodes (useful by debugging):

  • --osm_from_pickle – instead of querying solar panels coordinates from OSM, use the recently crawled data
  • --osm_postcodes_from_json – instead of querying postcode for each solar panel from OSM, use the recently crawled data

To use th newest FIT data – download the latest files here and update them manually according to Methodology section.

Metodology

FIT data

The FIT data used on the map come from this website. Each of the three files was manually pivoted (count for each Installation Postcode), filtered (Technology=Photovoltaic) and saved in data_preprocessing/UK_Installed_pannels as csv, with two columns:

  • first - postcode district names.
  • second - count of panels with given postcode

There are ~850k photovoltaic records in total; 14k of them (2%) with postal code UNKNOWN. The FIT files can be manually updated, accordingly to the specification above (unfortunately python crashed to open original xlsx files containing images).

Solar Pannels in OSM

The information about amount of solar panels provided for each postcode is retrieved in two steps:

  1. Solar panels are queried from OSM via overpass api.
  2. The closest postcode is queried for each solar panel via postcodes.io api

Then the statistics about number of solar panels are created. Panels are saved in OSM map in two formats - nodes (single point) and ways (area). To simplify, both single node and single way was assumed to be one solar panel.

Geolocations

The original file with postcode coordinates was downloaded from here (postcode-XXNN.* files). The file was preprocessed:

  1. Postcode shapes were simplified with Mapshaper asd saved as shp
  2. Original file was lacking several postcodes, which were manually added.
  3. File was saved as geojson: data_preprocessing/data/postcodes.js.

TODO:

  • Add missing postcodes to geojson (they disappeared due to postcode shapes simplification): BN42, CF47, CH47, DA18, DT1, FY2, G34, GL1, XH1, OX28, PE35, PL31, TA15, TF5, TN1, TN10
  • automate downloading and preprocessing FIT data
  • approximate UNKNOWN postcodes (from FIT data)

About

Daily pull UK solar panels data and visualise them using Mapbox & Leaflet.

https://sylwia.hs3.linux.pl/my_files/uk_photovoltaics_map/frontend/mapbox_uk.html

License:MIT License


Languages

Language:JavaScript 59.9%Language:Python 20.6%Language:HTML 11.6%Language:CSS 7.6%Language:Dockerfile 0.4%