Closed Bug 1653313 Opened 6 years ago Closed 5 years ago

Location to region algorithm has issues for ambiguous locations near borders

Categories

(Location :: General, defect, P2)

Tracking

(Not tracked)

RESOLVED MOVED

People

(Reporter: jwhitlock, Unassigned)

Details

The location at 51 latitude, 5.89 longitude is in a narrow part of the Netherlands bordered by Belgium and Germany, and illustrates issues with the algorithm that converts a location to a region, implemented in ichnaea/geocode.py.

Ichnaea uses two shape files for regions. The first has borders as expected, and the second adds a buffer to capture coastal regions. A "fast match" is also used to quickly geolocate without a shape file when a location is in the middle of a large area (the US, Russia, China, etc.). The region shapes were sourced from the Natural Earth project in 2015, from the 50m-resolution cultural shapes, and converted to GeoJSON by ichnaea/scripts/region_json.py.

For this location:

  • The fast match returns NL (the Netherlands), DE (Germany), BE (Belgium), and FR (France), so it fails the fast match
  • The buffered region check returns NL, DE, and BE, so it fails the second match
  • The precise check returns NL and DE. This may be a bug, may be due to the 50m resolution, or due to simplification when converting to GeoJSON. The precise match also fails.
  • The final check is to determine which buffered border the ambiguous location is most within. This is done by taking the distance from each border point to the location, and picking the largest. The NL shape includes Saba, an island in the Caribbean that is part of the Netherlands, which means NL wins the final check.

In this case, the correct answer is given (NL), but for the wrong reason. The final check should be changed:

  1. In the multi-polygon case, only consider the border polygons that enclose the location. This would eliminate Saba.
  2. Measure the signed distance to the border, and pick the border than the location is most within. There is probably a built-in function in one of our libraries to make this calculation.

We should probably also update our copy of the Natural Earth borders, and check that we are not discarding important data when converting to GeoJSON.

Priority: -- → P2
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → MOVED
You need to log in before you can comment on or make changes to this bug.