# Spatial-analyst, detecting bad ones from good positions GPS coordinates with QGIS?

I'm curious if someone else has been thru this problem and how it was solved.

Many years back people marked the position manually on a map to get waypoints of for example electric wire connection hubs, (I will call them "map-points") before we had smartphones with GPS utilities. This manually positioning inserted lots of really bad errors as people where good and bad to relate maps to real places.

Today I have collected several months of data from smartphones as they scan this positions once a day visiting. I want to use this data to update the positions - coordinates for the "map-points".

The problem is that smartphones are not the best devices for quality accurate positions. It can be from one meter to several kilometres in difference and I guess all depends on many parameters. But many of the positions are pretty darn good enough to use I think, I don't need exact 1 meter precision, if I can get within 10-15 meters all are great or at least within 25-50 meters.

First I want to find and select the bad ones (waypoints) from the good ones and remove them from the calculation to get as good data as possible for finding the best position. What I did was using QGIS running "join by lines" as the map-point and scan data has a related ID. From there I got the length of the line so I could see the distance for all scan data positions to the map-points. I added the distance to the scan data and run "statistic by categories" to get the median value of the distance from each connected map-points and then took this value to calculate the difference for each scan points (distance - median_value). I then divided the difference to the median value to get the percentage and used this to try to "pinpoint" the bad ones from the good ones. Below are some images... The green dot is the (manually done)map-point and red dots are the calculated "bad guys" and blue dots the "good" ones to use.

Next step I used the blue dots to get the median x/y-coordinates and use them to update the map-points coordinates.

Is this a good approach?

Any suggestions to refine this as I can see there could be more improvements but it takes to many steps into my approach. I have not seen this topic before in forums so I thought I'll check here.

This is the last step to pinpoint the bad ones (by trial and error) "stat_median" = the distance_median value in meters (from map-points) "diff" = the difference_value/distance_median. As you can see it is not perfect but better than do nothing...

`````` "stat_median" < 10 AND "diff" >= 2.00
OR
"stat_median" >= 10 AND "stat_median" < 25 AND "diff" >= 1.00
OR
"stat_median" >= 25 AND "stat_median" < 50 AND "diff" >= 0.60
OR
"stat_median" >= 50 AND "stat_median" < 75 AND "diff" >= 0.30
OR
"stat_median" >= 75 AND "stat_median" < 100 AND "diff" >= 0.23
OR
"stat_median" >= 100 AND "stat_median" < 200 AND "diff" >= 0.20
OR
"stat_median" >= 200 AND "stat_median" < 500 AND "diff" >= 0.17
OR
"stat_median" >= 500 AND "stat_median" < 1000 AND "diff" >= 0.15
OR
"stat_median" >= 1000 AND "stat_median" < 2000 AND "diff" >= 0.10
OR
"stat_median" >= 2000 AND "stat_median" < 5000 AND "diff" >= 0.05
OR
"stat_median" >= 5000 AND "diff" >= 0.02
``````     • Distance-based selection has a problem: two points at the same distance but in totally opposite directions can be considered as valid, although there are many other points in one direction and only that point in the opposite. I believe that the analysis should start from the deviation of two-dimensional positions (distance is a variable of one-dimension), and then establish a confidence interval on which to select good points. But honestly, statistics is not my specialty at all. – Gabriel De Luca Jan 30 at 21:56
• I learned not to answer about spatial statistics analysis, because although it seems to me a fundamental discipline in our work, a small error of concept can lead you to make gross errors of calculation. I recommend labeling the question with the `spatial-statistics` and/or `spatial-analyst` tag so that it can be easily seen by specialists. – Gabriel De Luca Jan 30 at 22:05
• added to the tag, yes I know the problem with the opposite directions of points, the weight of points makes a correction for it, is the best I can do for the moment but would love to see how it can be improved with a detailed explanation. – QGIS-user Jan 31 at 6:19
• Like @GabrielDeLuca, I hesitate to answer a statistical question. Maybe you should get a conceptual answer on Cross Validated, the stackexchange site for statistics. Once you figure out the best conceptual approach, then come back to GIS SE for help with implementing it. – csk Feb 1 at 17:44