nst-guide / data

Create map waypoints and layers from open data sources
https://nst-guide.github.io/data/
GNU General Public License v3.0
6 stars 0 forks source link

Find accurate length of trail #23

Open kylebarron opened 4 years ago

kylebarron commented 4 years ago

Figure out why current tracks are shorter than the "known" length of the trail (2653mi or 2662mi to Manning Park). The distances I'm getting are 2D: 2592 mi, 3D: 2607.9 mi.

Reproduce

hm = Halfmile()
trail = hm.trail_full(alternates=False)
merged = linemerge([*trail.geometry])
projected = reproject(merged, geom.WGS84, geom.CA_ALBERS)

Projected 2D length

projected.length
# 4171048.0624210313 m

Haversine

from haversine import haversine
dists = []
for a, b in zip(merged.coords, merged.coords[1:]):
    dist = haversine((a[1], a[0]), (b[1], b[0]))
    dists.append(dist)

sum(dists)
# 4171.3919978317 km

Projected 3D length

dists = []
for a, b in zip(projected.coords, projected.coords[1:]):
    x = b[0] - a[0]
    y = b[1] - a[1]
    z = b[2] - a[2]
    dist_m = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2))
    dists.append(dist_m)

sum(dists)
# 4196977.125911263 m
kylebarron commented 4 years ago

I'm getting smaller distances because the data on Halfmile's site is simplified:

In the next step, we reduce the horizontal point count so that all sections stay within Garmin’s 10K track point limit. We do this by applying the Ramer-Douglas-Peucker algorithm with a 1.9 meter sigma overall and, in more accurate sections, a 1.25 meter sigma