gtfs-validator icon indicating copy to clipboard operation
gtfs-validator copied to clipboard

Find stops that appear to be misplaced

Open mattwigway opened this issue 10 years ago • 5 comments

We want to find stops that are a long way away from the nearest stop. A good way to do this would be to compute the G function of all the stops and then see if this stop lies far from the distribution.

This seems like it would be slow, but this takes an imperceptible amount of time using one core of my machine, computing the G function for 14,000 randomly distributed stops (which is about how many there are in Chicago, the largest GTFS feed I know of).

library(spatstat)

# generate some random points
x <- runif(14000)
y <- runif(14000)

the.pp <- ppp(x, y)

est <- Gest(the.pp)

plot(est)

mattwigway avatar Oct 30 '14 17:10 mattwigway

Also, we don't have to do coordinate transforms; we can just multiply all of the longitudes by (radius of earth at equator)/(length of chord at agency latitude), and units will be invariant enough.

mattwigway avatar Oct 30 '14 18:10 mattwigway

K-function might be better to find groups of misplaced stops.

mattwigway avatar May 02 '16 14:05 mattwigway

How do you define misplaced?

  • likely to be out of order,
  • not near the shape,
  • or not near the others on the trip?

laidig avatar May 02 '16 16:05 laidig

I was thinking more of stops that are not near the rest of the stops in the entire feed, e.g. reversed lat/lon or at null island (0 lat 0 lon, due to math errors).

mattwigway avatar May 02 '16 16:05 mattwigway

Using the number of stops in of a cluster or iterative k-means are good formulations.

If machine learning approaches seem a bit confusing, I have a suggestion: If you know the overall precision you want to target, use geohashes as a heuristic. If you spot something that does not have the same prefix, calculate the adjacent hashes and compare with those.

https://en.wikipedia.org/wiki/Geohash

This library has a method for calculating adjacent hashes. https://github.com/davidmoten/geo

If you're interested in a test set, I have a copy of the Amtrak feed from 2013. I'm not able to think of a GTFS for a bigger region.

laidig avatar May 03 '16 01:05 laidig