-2

So, I am doing some work with data from an INS unit, in order to calculate the errors in its readings by integrating its velocity data over time to get a change in position, and then comparing that to its actual recorded change in position. The problem is that it gives its position with Latitude and Longitude in degrees (to 11 decimal places), and its documentation indicates that these are using the WGS84 standard, while its velocities are given in meters/second (to 10 decimal places).

I found this other question, but the answers to it were giving answers that assumed that the Earth is a sphere, while the WGS standard uses an ellipsoid, and it seems possible that using calculations that assume that the Earth is spherical might introduce errors into my calculations.

I'm intending to use Python to perform my data analysis with, so ideally answers should use Python as well, but using another language to do the data cleaning would work as long as I can save the cleaned data into a text file that Python can read.

nick012000
  • 159
  • 2
  • 12
  • 2
    You're asking about apples and salads. WGS84 specifies coordinates, not distances. Are you asking how to calculate distances between two coordinates perhaps? **All** GIS/spatial libraries do that already, for multiple reference systems, although you can easily find the algorithms online. – Panagiotis Kanavos Sep 10 '20 at 06:50
  • Does this answer your question? [Calculate distance between two latitude-longitude points? (Haversine formula)](https://stackoverflow.com/questions/27928/calculate-distance-between-two-latitude-longitude-points-haversine-formula) – Panagiotis Kanavos Sep 10 '20 at 06:50
  • @PanagiotisKanavos I wasn't given any libraries, just some data to analyze. Also, the accepted answer to that question you've linked assumes the Earth is spherical. – nick012000 Sep 10 '20 at 06:53
  • BTW if you want the details, check the duplicate question, or the relevant Wikipedia page(s). If you google for `WGS84 distance calculation` you'll find a lot of hits - that's how I found this duplicate and many other similar SO questions. If you add `Python` to the terms you can narrow it down – Panagiotis Kanavos Sep 10 '20 at 06:53
  • 1
    Did you *read the duplicate*? Have you tried googling? Or searching for similar SO questions? You haven't been given a library but *what's stopping you from using one*? You're asking about something common to *all* GIS problems, and Python is used for this for decades – Panagiotis Kanavos Sep 10 '20 at 06:54
  • @PanagiotisKanavos Yes, I have Googled, which is how I found the answer I linked in the OP. – nick012000 Sep 10 '20 at 06:55
  • 1
    Then what's your actual question? Because by now you should have found many spatial libraries. Which ones did you try? – Panagiotis Kanavos Sep 10 '20 at 06:56
  • @PanagiotisKanavos My question is "how do I do this?" My Google Search hasn't turned anything immediately obvious. I just found pyproj which might work, but maybe it works on a spherical Earth model - and there's nothing obvious one way or the other. – nick012000 Sep 10 '20 at 07:09
  • This is the same as claiming Python isn't used for GIS, or that data scientists don't do spatial, which is obviously wrong. Google `WGS84 Python` and the first hit [is this](https://www.earthdatascience.org/courses/use-data-open-source-python/intro-vector-data-python/spatial-data-vector-shapefiles/intro-to-coordinate-reference-systems-python/). Not only is WGS84 supported, so are shapefiles and plotting. That article uses geopandas among other packages – Panagiotis Kanavos Sep 10 '20 at 07:12
  • @PanagiotisKanavos Different people get different Google results. My first Google result was a StackExchange link. – nick012000 Sep 10 '20 at 07:14
  • Second result is [How do I convert WGS84 lat,long points from degrees to meters in Python?](https://gis.stackexchange.com/questions/260992/how-do-i-convert-wgs84-lat-long-points-from-degrees-to-meters-in-python) One of the answers uses pyproj. Lots more answers from `gis.stackexchange.com` too – Panagiotis Kanavos Sep 10 '20 at 07:14
  • @PanagiotisKanavos Yes, I saw that one as well, but the answer for that one was specific to Europe. I also didn't realize that SE site existed prior to asking this question. – nick012000 Sep 10 '20 at 07:21

1 Answers1

0

Perhaps you could use LatLon (or for python3 LatLon23), which does enable treating eearth as an ellipsoid.

see an example code using LatLon23 for python3:

from LatLon23 import LatLon, Latitude, Longitude
palmyra = LatLon(Latitude(5.8833), Longitude(-162.0833)) # Location of Palmyra Atoll
honolulu = LatLon(Latitude(21.3), Longitude(-157.8167)) # Location of Honolulu, HI
distance = palmyra.distance(honolulu) # WGS84 distance in km
print(distance)

print(palmyra.distance(honolulu, ellipse = 'sphere')) # FAI distance in km

initial_heading = palmyra.heading_initial(honolulu) # Heading from Palmyra to Honolulu on WGS84 ellipsoid
print(initial_heading)

hnl = palmyra.offset(initial_heading, distance) # Reconstruct Honolulu based on offset from Palmyra
print(hnl.to_string('D')) # Coordinates of Honolulu

snatchysquid
  • 1,283
  • 9
  • 24
  • Does that package work in Python 3? That page says it's only been tested in Python 2.7. – nick012000 Sep 10 '20 at 06:49
  • 2
    This should be a comment as it doesn't really answer the question. Although the answer here is that most if not *all* spatial libraries can handle ellipsoids. – Panagiotis Kanavos Sep 10 '20 at 06:51