# Reduce GPS data set by distance

I have a set of GPS coordinates, created by a GPS sensor and a Raspberry Pi. I am poling the sensor at 10hz and recording the data into an SQL DB on the Pi. The system is on top of my car (and part of a house scanning tool for the building industry). The issue is that I am driving at different speeds. In some instances I have to stop to allow other cars to pass, all the while record GPS location at 10hz.

Once the data is recorded I want to post-process the GPS data and output a reduced list of coordinates so that I have locations approximately 1 metre apart.

I know I can maybe use Pandas for this, but have no idea where to start.

This is an example data set:

```51.80359349246259,-4.741180850463812
51.80361005410784,-4.740873766196046
51.80351890237921,-4.7415190658979895
51.803152371942325,-4.74057836870229
51.80352232936482,-4.740392650792621
51.80361261925252,-4.740896906964529
51.803487420307796,-4.7402764541541265
51.80353017387817,-4.74136689657748
51.80287372471039,-4.741218904144232
51.80326530703784,-4.740193742088211
```

Any help will be very much appreciated.

I worked a solution based on finding the distance suggested by @Ferris. The ‘mpu.haversine_distance’ function returns a distance in KM’d between two lat/lng pairs. I multiply by 1000 to display as metres. I then add these distances up and if it gets over 1 metre I report back that lat/lng. This can be adjusted to 3 metres etc.

```import mpu

def processTheSet(batch):
mycursorll = mydb.cursor()
sqlll = "SELECT latt, longg FROM interPol WHERE batchID = %s ORDER BY `fileTime`"
batchI = (batch,)
mycursorll.execute(sqlll, batchI)
firstResult = mycursorll.fetchone()
firstLat = float(firstResult)
firstLng = float(firstResult)
myresultll = mycursorll.fetchall()
i = 0
count = 0
counter = 0
dist = 0
for x in myresultll:
i = i + 1
thisLat = float(x)
thisLong = float(x)
dist = mpu.haversine_distance((firstLat, firstLng), (thisLat, thisLong)) * 1000
firstLat = thisLat
firstLng = thisLong
counter = counter + dist
if counter > 1:
count = count + 1
counter = 0
print(thisLong, ",", thisLat)
```