2

I have a set of GPS coordinates (x, y) along with heading information. The heading for these coordinates is more or less the same and the coordinates are within a few meters of each other. How can I use QGIS (or any other tool) to find the mean and standard deviation of these GPS coordinates along the heading, i.e. looking to rotate the X, Y plane along the heading direction and then find the mean and SD.

Thanks!

3
  • In what format are your coordinates? Just a text file? A shapefile?
    – Jake
    Nov 21, 2013 at 21:38
  • @Jake: The coordinates are in a text file.
    – user24236
    Nov 21, 2013 at 22:58
  • @Mohan: Did I misunderstand your question?
    – Jake
    Dec 3, 2013 at 17:40

1 Answer 1

1

You can do this using Python (or Matlab, or R ...).

The following Python script takes a file name and an angle as arguments, and reads the data (assumes that each row contains one coordinate), rotates the coordinates, and calculates the mean and standard deviation of the rotated coordinates:

import numpy as np
import sys

filename = sys.argv[1]
angle = np.deg2rad(float(sys.argv[2]))

rotationMatrix = np.array([[np.cos(angle), np.sin(angle)],[-np.sin(angle),np.cos(angle)]])

coordinates = np.loadtxt(filename)
transformed = np.dot(coordinates, rotationMatrix)

print "Mean: " + str(np.mean(transformed,0))
print "Std dev: " + str(np.std(transformed,0))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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