gregrs-uk / python-fhrs-osm

Python tools and Leaflet maps for downloading, comparing and visualising Food Hygiene Rating Scheme (FHRS) and OpenStreetMap data
http://gregrs.dev.openstreetmap.org/fhrs/
GNU General Public License v3.0
8 stars 2 forks source link

Check distance between OSM and FHRS location for matches? #28

Closed gregrs-uk closed 7 years ago

gregrs-uk commented 7 years ago

Query the database to see whether this would be worth implementing

gregrs-uk commented 7 years ago

Graphs for distance between OSM and FHRS position for matches

boxplot histogram

Statistically, the upper fence (Q3 + 1.5xIQR) is 187m.

Distances over 187m

Total 7.2% of matches. Top districts by number of matches with a distance > 187m

                 name                  | number 
---------------------------------------+--------
 Rushcliffe District (B)               |     91
 Erewash District (B)                  |     70
 City of Nottingham (B)                |     65
 Broxtowe District (B)                 |     52
 Breckland District                    |     51
 South Gloucestershire                 |     47
 Wellingborough District (B)           |     36
 Cheshire East (B)                     |     34
 Highland                              |     29
 Ashfield District                     |     26

Distances over 250m

Total 4.0% of matches. Top districts by number of matches with a distance > 250

                name                | number 
------------------------------------+--------
 Rushcliffe District (B)            |     52
 Erewash District (B)               |     40
 City of Nottingham (B)             |     40
 Broxtowe District (B)              |     33
 South Gloucestershire              |     27
 Breckland District                 |     23
 Cheshire East (B)                  |     22
 Highland                           |     22
 Wellingborough District (B)        |     20
 Argyll and Bute                    |     14

Distances over 500m

Total 1.4% of matches. Top districts by number of matches with a distance > 500m

                name                | number 
------------------------------------+--------
 Rushcliffe District (B)            |     28
 City of Nottingham (B)             |     15
 Broxtowe District (B)              |     14
 Erewash District (B)               |     10
 Bolsover District                  |      9
 Highland                           |      8
 Breckland District                 |      7
 South Gloucestershire              |      6
 Argyll and Bute                    |      6
 Wirral District (B)                |      6
gregrs-uk commented 7 years ago

The suggest matches distance (currently 250m) should be equal to or less than whatever value is chosen for a warning about the distance between OSM and FHRS positions.

gregrs-uk commented 7 years ago

Example query

select osm_name, st_distance(osm_geog, fhrs_geog) as distance from compare
where osm_district_id = 1 and osm_geog is not null and fhrs_geog is not null
and st_dwithin(osm_geog, fhrs_geog, 500, false) is false
order by distance desc;