Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Please note that this tool has now been superseded by FHODOT.

Python tools for downloading and comparing Food Hygiene Rating Scheme (FHRS) and OpenStreetMap (OSM) data and finding possible matches between it, together with Leaflet slippy maps for visualising the data.

Maps and statistics for Great Britain

Please follow the link for FHRS comparison maps and statistics for Great Britain, kindly hosted on the OpenStreetMap dev server and updated daily.


  • Download OpenStreetMap and FHRS data and parse it into a PostgreSQL/PostGIS database
  • Use database views to compare OpenStreetMap and FHRS data and find anomalies, and to find possible matches between OSM nodes/ways and FHRS establishments based on proximity and similarity of names
  • Export HTML pages with statistics and Leaflet slippy maps, allowing users to visualise OSM/FHRS data as well as to review possible matches between FHRS and OSM data and import useful tags into JOSM


  • Requires PostGIS 2.3
  • Tested using:
    • Ubuntu 16.04
    • Python 2.7
    • PostgreSQL 9.5
    • PostGIS 2.3 (installed using PGDG package)


  1. Download the Boundary Line shapefiles from Ordnance Survey and place the four district_borough_unitary_region.* files in the shapefiles directory. (These are used to compute which district FHRS establishments and OSM entities are in so that relavitely small GeoJSON files can be created, one for each district)
  • Run, which should:
    • Install overpy module
    • Install psycopg2-binary module
    • Install shapely module
    • (Re)create PostgreSQL database (called fhrs by default, see
    • Enable PostGIS and fuzzystrmatch extensions
    • Run to import district boundaries from shapefiles
    • Run python to download FHRS data and upload to the PostgreSQL database
      • By default, data for the Rugby and Warwick areas are downloaded, but this can be altered in
      • FHRS data is downloaded one authority at a time
    • Run python to download OpenStreetMap data and upload to the PostgreSQL database
      • OSM ways are simplified to a single point at the center of the way.
      • By default, data is downloaded using Overpass API to match the bounding box of the FHRS data present in the database. The bounding box can be altered in
      • The OSM tag/value pairs to query can also be modified. Please see the docstrings in fhrs_osm/ for details
      • If OSM data for a large geographical area is required, it's best to filter a PBF file (e.g. one obtained from GeoFabrik) using Set use_xml_file=True in to parse the filtered file rather than querying Overpass API
    • Run python to compute which district FHRS establishments and OSM entities are in and to create the database views
    • Run python to create HTML and GeoJSON files for each district which contains more than a certain threshold of FHRS data


  • Open html/index.html in a browser to show a list of districts. Click on a district to show a page with statistics and maps (see below) for a particular district

Overview map

Example overview map

Multiple establishments within approx. 3.5 metres of each other are aggregated. (This is especially necessary because the FHRS position data is reverse geocoded from postcodes.)

  • Locations with at least one OSM entity with an fhrs:id value not present in the FHRS data (e.g. establishments that have closed) or with a missing/mismatched postcode are red
  • Locations with at least one OSM entity with no fhrs:id tag and no postcode are orange
  • Locations with at least one OSM entity with no fhrs:id tag but with a postcode are purple
  • Locations with at least one establishment from the FHRS database with no matching OSM entity (matched using fhrs:id tag) are blue
  • Locations with only OSM entities with a valid fhrs:id value and matching addr:postcode or not:addr:postcode are green

Clicking on a marker shows a popup with the name of any OSM entities or FHRS establishments and a link to the relevant OSM node/way or FHRS establishment web page. If the marker represents an OSM entity, the popup also includes a link which allows the user to edit the entity in JOSM

Suggested matches map

Example suggested matches map

By default, this map shows OSM entities with possible matches in the FHRS database, based on the following criteria:

  • < 250m distance
  • Either FHRS name contains OSM name within it or names are closely matched using Levenshtein distance algorithm

Clicking on a marker shows a popup with links to the OSM node/way web page and the FHRS establishment web page, as well as a link which allows the user to copy relevant tag/value pairs into JOSM


Copyright © gregrs-uk 2016, published under the GNU GPL v3.0


Python tools and Leaflet maps for downloading, comparing and visualising Food Hygiene Rating Scheme (FHRS) and OpenStreetMap data