# Range in Earth's coordinates

**URL:** https://discourse.julialang.org/t/range-in-earths-coordinates/58287
**Category:** New to Julia
**Tags:** question, geo, gmt
**Created:** [March 31, 2021, 11:59am UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287 "2021-03-31T11:59:36Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)
#### Post date: [March 31, 2021, 11:59am UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/1 "2021-03-31T11:59:37Z")

</div>

Hi every one! I am looking for an efficient way to generate equally spaced points between two coordinates on Earth’s Surface. Something like:

range(point1, point2, length=10)

I know there is the GMT wrapper, but it needs distances and it is a bit slow.

Any ideas?

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [March 31, 2021, 12:51pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/2 "2021-03-31T12:51:52Z")

</div>

> [@marianoarnaiz](#):
>
> it is a bit slow.

Using the example from the `project` module (2nd run)

```julia
julia> tic(); D = project(origin=(-50,10), end_pt=(-10,30), step=10, km=true);toc()
elapsed time: 0.0168785 seconds

```

---

<div class="post-metadata">

### Author: ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)
#### Post date: [March 31, 2021, 12:59pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/3 "2021-03-31T12:59:44Z")

</div>

Maybe Inwas using it wrong? I wish it could handle x,y,z too haha

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [March 31, 2021, 1:16pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/4 "2021-03-31T13:16:32Z")

</div>

What do you mean by _x,y,z_?  
One limitation of this method (using the `proj` module) is that computation is on the sphere, not the ellipsoid.

---

<div class="post-metadata">

### Author: ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)
#### Post date: [March 31, 2021, 1:29pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/5 "2021-03-31T13:29:03Z")

</div>

The module can produce points from a point to another:

D = project(origin=(-50,10,0), end\_pt=(-10,30,-100), step=10, km=true)

But I wish it could:

D = project(origin=(-50,10,0), end\_pt=(-10,30,-100 [this depth in km]), step=10, km=true).

The problem is that I am trying to find a good way to interpolate a Ray inside the Earth, but normal interpolators do not understand that the Earth has limits and it is not a Cartesian system HAHAHA.

---

<div class="post-metadata">

### Author: ![mihalybaci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihalybaci/32/13528_2.png) [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)
#### Post date: [March 31, 2021, 1:34pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/6 "2021-03-31T13:34:11Z")

</div>

Have you looked into using [Geodesy.jl](https://github.com/JuliaGeo/Geodesy.jl)? It may not have exactly what you need, but maybe it would be easy enough to come up with a custom solution.

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [March 31, 2021, 1:43pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/7 "2021-03-31T13:43:07Z")

</div>

But rays are curved because velocity increases with depth. Interpolating along those rays is a kind of creating flow lines when velocity changes. Otherwise it’s just a linear interpolation between 2 3D points.

---

<div class="post-metadata">

### Author: ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)
#### Post date: [March 31, 2021, 1:48pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/8 "2021-03-31T13:48:58Z")

</div>

I have a few problems in my hands. The project output is great as an initial ray for ray tracing. But as the ray traces I need to interpolate the nodes I have in the ray (say 17 nodes and interpolate 10 times along the path of the ray). This is complicated because the interpolation libraries do not understand the “roundness of the Earth”.

By this I mean, if I interpolate from

-67,10 to 10,20

It works

But from

-175, 0 to 175, 0 (via the minor arc) … I don’t know how to get this done well.

 ![3D](https://global.discourse-cdn.com/julialang/original/3X/3/c/3c96a74b6295ff50dd2969143374edab64831fc7.png)

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [March 31, 2021, 1:58pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/9 "2021-03-31T13:58:18Z")

</div>

Is this a GMT plot? Cool.

I’m still not sure that I fully understand the problem. Earth is not “round” on the vertical direction but due to velocity increase the rays are curved and any interpolation along the rays paths must take that into account.  
You can try also the GMT forum, there are seismologist there as well and may someone will have an idea.

---

<div class="post-metadata">

### Author: ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)
#### Post date: [March 31, 2021, 2:01pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/10 "2021-03-31T14:01:34Z")

</div>

Yes, a simple plot to see it my ray tracer works well hehe.

“roundness of the Earth”.

By this I mean, if I interpolate from

-67,10 to 10,20

It works

But from

-175, 0 to 175, 0 (via the minor arc) … I don’t know how to get this done well.

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [March 31, 2021, 2:10pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/11 "2021-03-31T14:10:28Z")

</div>

Interpolating along a small circle of a sphere should be simple. Just use normal `range` with the geographical coordinates and then compute the arc length for each interval knowing the radius of the circle at that latitude. For ellipsoidal computations I think the **-G** option of `mapproject` can be useful too. But again, this is not going on depth too.

---

<div class="post-metadata">

### Author: ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)
#### Post date: [April 1, 2021, 12:40pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/12 "2021-04-01T12:40:48Z")

</div>

Let me give it a try! Thanks for the idea @joa-quim

---

<div class="post-metadata">

### Author: ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)
#### Post date: [April 1, 2021, 4:17pm UTC](https://discourse.julialang.org/t/range-in-earths-coordinates/58287/13 "2021-04-01T16:17:05Z")

</div>

Also see [here](https://discourse.julialang.org/t/geodesy-how-to-calculate-the-straight-line-distance-between-two-locations-which-is-represented-by-longitude-and-latitude/19984/18)
