Calculate all mid points of a line at a given interval

Click For Summary

Discussion Overview

The discussion revolves around calculating midpoints along a line defined by two geographical coordinates (latitude and longitude) at specified intervals, specifically 1 meter. Participants explore the challenges of using standard distance formulas on spherical coordinates and consider approximations for calculations.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Exploratory

Main Points Raised

  • One participant seeks to calculate (x,y) coordinates every 1 meter along a line between two points defined by latitude and longitude.
  • Another participant points out that the formula used is not suitable for spherical coordinates and suggests that the distance should account for the Earth's curvature.
  • A correction is made regarding the coordinates, clarifying the correct latitude and longitude values for the points near Newcastle, England.
  • A model is proposed using the Earth's radius to approximate distances, with calculations provided for the conversion of degrees of latitude and longitude into meters.
  • Participants discuss the calculated distance between the two points and how to divide this distance into segments for the desired interval.
  • A step value is derived for incremental calculations of the midpoints along the line.

Areas of Agreement / Disagreement

Participants generally agree on the need to adjust calculations for the spherical nature of Earth, but there is no consensus on the precision required for the calculations or the best approach to take.

Contextual Notes

Limitations include assumptions about the Earth's shape and the precision of the calculations, as well as the potential need for adjustments based on the specific geographic context of the points involved.

Who May Find This Useful

Individuals interested in geographic information systems (GIS), cartography, or programming related to mapping and distance calculations may find this discussion relevant.

Rich2020
Messages
4
Reaction score
0
Hi guys & girls, I'm using Google maps coordinates to draw a line and want to divide the line by its length, giving segments where the length of each segment is equal to 1.

EG:

P1
p1.lat = 54.97435323116719
p1.lng = 54.9742647135445

P2
p2.lat = -1.6116368025541306
p2.lng = -1.6115100681781769

let's assume that the unit of measure is meter.

Now, between the points p1 and p2, I need to calculate the (x,y) every 1 meter - along the length of the line.

My attempt results in:
x = -0.000006809047899462957, y = 0.00000974879815028264

but I'm not sure if that is correct.

I use the formula:
x = (x2-x1) / distance
y = (xy-xy) / distance

Is this correct? If not, how can I do this?
 
Physics news on Phys.org
The formula you used is for the distance between points in a pane - latitude and longitude are points on the surface of a sphere. The distance between the two points is the curved distance across the surface of the Earth.
 
Rich2020 said:
P1
p1.lat = 54.97435323116719
p1.lng = 54.9742647135445

P2
p2.lat = -1.6116368025541306
p2.lng = -1.6115100681781769
I'm guessing that you meant:
P1
p1.lat = 54.97435323116719
p1.long = -1.6116368025541306

P2
p2.lat = 54.9742647135445
p2.long = -1.6115100681781769

These are points near New Castle, England. These points are only about 10 meters apart and not too close to the North or south poles. So, unless we're sticklers for precision, we won't need to deal with spherical geometry and great circle distances.

Another approximation we will use is the shape of the Earth. We will assume a sphere of radius 6353 meters.

So, with this model:

1 degree of latitude = 2 pi R / 360 = (2 · 3.1416 · 6353 / 360) KM
= 110.881 Km

1 degree of longitude = 2 pi R cos(lat) / 360 = cos(54.974°) · 110.88 KM = 0.573944 · 110.88 KM
= 63.639 Km

Our deltas are P2-P1:
D
d.lat = 54.9742647135445 - 54.97435323116719 = -0.00008851762269
d.long = -1.6115100681781769 - -1.6116368025541306 = 0.0001267343759537

The length of D will be about:
√ ( (d.lat*110.881)² + (d.long*63.639)² ) Km = √161.3809 m
= 12.703 meters

So we need to divide D into 12.703 pieces, although you may want to round to 13:
S = D/12.703
S.lat = D.lat/12.703 = -.0000069679°
S.long = D.long/12.703 = .0000099762°

S is a step value, so the points will be P1 + nS where n=1, 2, ... 12.
 
  • Like
Likes   Reactions: 1 person
Thanks so much! Here is a link to the results in action: http://jsfiddle.net/FPby3/

I still need to tweek it a little but it's doing what I need so thank you very much! I shall name the marker array after you!
 
Rich2020 said:
I shall name the marker array after you!
I am honored!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
Replies
13
Views
4K
  • · Replies 14 ·
Replies
14
Views
4K
Replies
14
Views
11K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
12
Views
2K
Replies
5
Views
2K
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K