I'm trying to find the coordinates of my point of attention (point X,marked blue). I used the GPS device of my car to collect the coordinates according to where I parked my vehicle each time I visited point x. So after following this exercise for 16 days, I managed to obtained 16 sets of coordinates, spread round about my point of attention.

After plotting these coordinates on the map, I observed the following: Twice or thrice out of ten times, my GPS device gave a wrong set of coordinates which turned out to be quiet far from point X. Also due to traffic, occasionally I'm unable to park close to point x and hence in this case too, the coordinates obtained are far from point X.

Problem : From the 16 sets of coordinates obtained, what process do I use to narrow down to one set of coordinates which is in close proximity to my point of attention (point X)?

Image supports the problem description above

  • do you have information about PDOP provided by your GPS device ? this could help you identify the unreliable points. – radouxju Sep 4 '15 at 12:20
  • I would put this in answers but I am not sure if this is exactly what you are trying to do, but tossing the outliers and using a least squares adjustment i believe can solve your problem. utdallas.edu/~aiken/GPSCLASS/ch11.pdf – ed.hank Sep 4 '15 at 13:46

One way to approach this interesting problem is to view it as a robust estimator of the center of a bivariate point distribution. A (well-known) solution is to peel away convex hulls until nothing is left. The centroid of the last non-empty hull locates the center.

(This is related to the bagplot. For more information, search the Web for "convex hull peeling multivariate outlier.")


The result for the 16 illustrated points is shown as the central triangle in this map. The three surrounding polygons show the successive convex hulls. The five outlying points (30% of the total!) were removed in the first two steps.

The example was computed in R. The algorithm itself is implemented in the middle block, "convex peeling." It uses the built-in chull routine, which returns the indexes of points on the hull. These points are removed by means of the negative indexing expression xy[-hull, ]. This is repeated until the last points would be removed. In the last step, the centroid is computed by averaging the coordinates.

Note that in many cases projecting the data is not even necessary: the convex hulls will not change unless the original features span the antimeridian (+/-180 degree longitude), either pole, or are so extensive that the curvature of segments between them will make a difference. (Even then the curvature will be of little concern, because the peeling will still converge to a central point.)

# Project the data.
dy <- c(8,7,5,10,7,17,19,19,21,22,22,22,24,24,26,26)
dx <- c(66,67,66,89,89,79,78,76,75,81,78,77,75,80,77,83)
lat <- (28.702 + dy/1e5) / 180 * pi
lon <- (77.103 + dx/1e5) / 180 * pi
y <- dy
x <- cos(mean(lat)) * dx
# Convex peeling.
xy <- cbind(x, y)
while(TRUE) {
  hull <- chull(xy)
  if (length(hull) < nrow(xy)) {
    xy <- xy[-hull, ]
  } else {
    xy.0 <- matrix(apply(xy, 2, mean), 1, 2)
# Plot the data `xy` and the solution `xy.0`.
plot(range(x), range(y), type="n", asp=1)
points(x, y, pch=21, bg="#a01010")
points(xy.0, pch=24, cex=1.2, bg="#404080")
| improve this answer | |
  • Nice. One thought: would it be appropriate to discard any likely bad data before computing hulls - based solely on how it was collected (inability to park close by) but NOT based on inspection of the data? – Simbamangu Sep 6 '15 at 8:18
  • @Simba That is a reasonable approach. – whuber Sep 7 '15 at 16:47
  • If we have multiple sites like this, each with different number of observations(like this one had 16), in an excel file, how would we modify the code for that. – user3587184 Oct 16 '15 at 7:23
  • @user3587184 Ideally, you would not do the work in Excel. If you must, then write a macro to loop over the groups of observations. – whuber Oct 16 '15 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.