# Midpoint of a line

**URL:** <https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018>\
**Category:** Q&A\
**Tags:** gmt\
**Created:** [July 1, 2025, 8:23pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018 "2025-07-01T20:23:28Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![EvanPi](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@EvanPi](https://forum.generic-mapping-tools.org/u/EvanPi)\
**Post date:** [July 1, 2025, 8:23pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/1 "2025-07-01T20:23:28Z")

</div>

Hi,  
I am trying to get a midpoint of a line.  
`awk -F, '{mid_lon=($1+$3)/2; mid_lat=($2+$4)/2; print mid_lon, mid_lat}' dredgeinfo.txt > dredgemidpoint.txt`  
that should take the average of 2 points, but it appears that this point isnt quite on line conencting the two points. i have a feeling this is some sort of projection thing, where the midpoint isnt calculated along a great circle or something similar. How can I do this with GMT?

 ![Screenshot from 2025-07-01 16-17-55](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/4/48767700b5b5d4e119d8c645a6cdd030395f8c79.jpeg)

Location of 2 endpoints:  
`-104.888	-4.559`  
`-104.877	-4.553`

---

<div class="post-metadata">

**Author:** ![thwbecker](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/thwbecker/32/1215_2.png) [@thwbecker](https://forum.generic-mapping-tools.org/u/thwbecker)\
**Post date:** [July 1, 2025, 9:44pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/2 "2025-07-01T21:44:40Z")

</div>

GMT by default uses a great circles to connect geographic points unless that is suppressed with the -A flag. Turned around, to get the mid point distance in gegraophic coordinates you can use a script like this one

> <https://github.com/thwbecker/awk/blob/main/pointfromtwoloc.awk>

assuming spherical Earth or use a projection package to get more accurate results.

---

<div class="post-metadata">

**Author:** ![jaltekruse](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jaltekruse/32/1607_2.png) [@jaltekruse](https://forum.generic-mapping-tools.org/u/jaltekruse)\
**Post date:** [July 2, 2025, 5:17pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/3 "2025-07-02T17:17:24Z")

</div>

Your awk print statement may be truncating the coordinates, try `printf("%f %f",mid_lon,mid_lat)` (when I tried this, I get the same results from the GMT solution below and both plot on the line). To stay within GMT, I think `gmt spatial` can find the midpoint:

```bash
$ cat tmp_line.gmt 
>
-104.888 -4.559
-104.877 -4.553

$ gmt spatial -Qk tmp_line.gmt
-104.8825 -4.556 1.38849721954

```

Here, `gmt spatial` prints the coordinates of the midpoint and the total length of the line (1.39 km).

`mapproject` can calculate the distance and azimuths from the endpoints to the midpoint to verify that the azimuths from the endpoints to the midpoint are 180 degrees apart and the distances from the endpoints to the midpoint are half of the total length:

```bash
$ gmt mapproject -G-104.8825/-4.556+uk tmp_line.gmt -Af-104.8825/-4.556
>
-104.888 -4.559 241.312977761 0.694247508686
-104.877 -4.553 61.3135153114 0.694249710865

```

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 2, 2025, 10:05pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/4 "2025-07-02T22:05:17Z")

</div>

Well, strictly speaking it doesn’t compute the mid-point. It does compute the centroid of the polygon. But since the it closes the line and apparently thinks it’s a polygon, the result is the same 😃

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [July 4, 2025, 10:09pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/5 "2025-07-04T22:09:03Z")

</div>

> [@jaltekruse](#):
>
> ```auto
> $ gmt mapproject -G-104.8825/-4.556+uk tmp_line.gmt -Af-104.8825/-4.556
> >
> -104.888 -4.559 241.312977761 0.694247508686
> -104.877 -4.553 61.3135153114 0.694249710865
> 
> ```

also @Joaquim

Something I got VERY puzzled over: when I run the above without `-G...`, the calculate azimuths become different:

```auto
gmt mapproject tmp_line.gmt -Af-104.8825/-4.556
-104.888	-4.559	241.389540334
-104.877	-4.553	61.389540334

```

i.e. `61.389540334` vs `61.3135153114`

Is this me doing something wrong? Thanks! I’ve been making some azimuth calculations for oblique Mercator `-Joa...` specification, and this makes a lot of difference.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 5, 2025, 10:49am UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/6 "2025-07-05T10:49:33Z")

</div>

OK, things I found.  
First let me start with the _correct_ ellipsoidal answer to the mid point (these GMT.jl functions use PROJ).

```auto
julia> invgeod([-104.888, -4.559], [-104.877, -4.553])
(1389.3356054500066, 61.47443481564943, 61.473561047920725)

```

we get, distance, azimuth at starting point, azimuth at end point. Now compute the midpoint

```auto
julia> geod([-104.888, -4.559], 61.47443481564943, 1389.3356054500066/2)
([-104.88249997720496 -4.556000021167548], 61.47399778643971)

```

second value is the azimuth at midpoint. The midpoint coordinates are a bit different of those by `gmtspatial`. Likely the reason is that `gmtspatial` is not able to compute centroids using the ellipsoidal coordinates.

Now `mapproject -A` has the same problem. It ignores the ellipsoidal request and the azimuths are different then those of GMT.jl

```auto
C:\v>mapproject a.dat -Af-104.88249997720496/-4.556000021167548 -je
-104.888 -4.559 241.389810108
-104.877 -4.553 61.3892705594

C:\v>mapproject a.dat -Af-104.88249997720496/-4.556000021167548
-104.888 -4.559 241.389810108
-104.877 -4.553 61.3892705594

```

This is a bug, Specially since if we use the **-G** and **-je** then results match those of PROJ … and we get a weird warning

```auto
mapproject a.dat -G-104.88249997720496/-4.556000021167548 -Ab-104.88249997720496/-4.556000021167548 -je
mapproject [WARNING]: Your distance mode (Great Circle) differs from your -j option (Geodesic) which takes precedence.
mapproject [WARNING]: Your distance mode (Great Circle) differs from your -j option (Geodesic) which takes precedence.
-104.888 -4.559 61.4744348127 694.667802659
-104.877 -4.553 -118.526438955 694.667802659

```

Now both GMT and PROJ azimuths (61.4744348127 _vs_ 61.47443481564943) match up to the 8th decimal. Note that I used **-Ab** instead of **-Af** given the bit weird way that GMT uses to define with respect to which point we refer as _forward_ and _backward_ azimuths.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 5, 2025, 12:00pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/7 "2025-07-05T12:00:11Z")

</div>

More. The problem is that with only **-A** it is not detecting that the input is geographical. Adding **-fg** makes it work.

```auto
mapproject a.dat -AB-104.88249997720496/-4.556000021167548 -fg
-104.888 -4.559 61.4744348127
-104.877 -4.553 -118.526438955

```

and

```auto
mapproject a.dat -Ab-104.88249997720496/-4.556000021167548 -fg -je
mapproject [WARNING]: Your distance mode (Great Circle) differs from your -j option (Geodesic) which takes precedence.
-104.888 -4.559 61.4744348127
-104.877 -4.553 -118.526438955

```

These upper case F,B must be some old stuff before the **-je** introduction and should be removed in favor of later.

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [July 5, 2025, 12:24pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/8 "2025-07-05T12:24:29Z")

</div>

Thanks a lot!

what about `-je` and `gmt spatial`?

```auto
gmt spatial -Qk tmp_line.gmt -je
gmtspatial [WARNING]: Your distance mode (Great Circle) differs from your -j option (Geodesic) which takes precedence.
-104.8825	-4.556	1.38933560532
gmt spatial -Qk tmp_line.gmt
-104.8825	-4.556	1.38849721954

```

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [July 5, 2025, 12:35pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/9 "2025-07-05T12:35:16Z")

</div>

> [@Joaquim](#):
>
> ```auto
> julia> invgeod([-104.888, -4.559], [-104.877, -4.553])
> (1389.3356054500066, 61.47443481564943, 61.473561047920725)
> 
> ```

that’s kind of weird as CLI `geod` reports `-118.52643895207179` instead of `61.473561047920725`

```auto
echo -4.559 -104.888 -4.553 -104.877 | invgeod +ellps=WGS84 -F "%.17g" -f "%.17g" 
61.474434815656934	-118.52643895207179	1389.3356054500071

```

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 5, 2025, 1:49pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/10 "2025-07-05T13:49:20Z")

</div>

> [@mkononets](#):
>
> that’s kind of weird as CLI `geod` reports

Must see what `invgeod` CLI says it reports. The [one](https://www.generic-mapping-tools.org/GMTjl_doc/documentation/gdalfuns/#invgeod) via GMT.jl says

### Returns

dist - A scalar with the distance between point 1 and point 2 (meters). Or a vector when lonlat1|2 have more than one pair of points.

az1 - azimuth at point 1 (degrees) ∈ [-180, 180)

az2 - (forward) azimuth at point 2 (degrees) ∈ [-180, 180)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 5, 2025, 1:50pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/11 "2025-07-05T13:50:34Z")

</div>

> [@mkononets](#):
>
> what about `-je` and `gmt spatial`?

That’s what I said. Centroid computation seem to ignore **-j** (but length, not).

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [July 5, 2025, 2:53pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/12 "2025-07-05T14:53:15Z")

</div>

> [@Joaquim](#):
>
> Must see what `invgeod` CLI says it reports. The [one](https://www.generic-mapping-tools.org/GMTjl_doc/documentation/gdalfuns/#invgeod) via GMT.jl says
> 
> ### Returns
> 
> dist - A scalar with the distance between point 1 and point 2 (meters). Or a vector when lonlat1|2 have more than one pair of points.
> 
> az1 - azimuth at point 1 (degrees) ∈ [-180, 180)
> 
> az2 - (forward) azimuth at point 2 (degrees) ∈ [-180, 180)

CLI `geod` apparently reports the same, _forward and back azimuths and distance between  
an initial and terminus point latitudes and longitudes (inverse)_. `180 - 118.52643895207179 = 61.47356104792821` is the same as `61.473561047920725` to the 11th decimal digit.

Both `man geod` and [geod — PROJ 9.6.2 documentation](https://proj.org/en/stable/apps/geod.html) are less detailed though:

```auto
geod (direct) and invgeod (inverse) perform geodesic (Great Circle)
       computations for determining latitude, longitude and back azimuth of a
       terminus point given a initial point latitude, longitude, azimuth and
       distance (direct) or the forward and back azimuths and distance between
       an initial and terminus point latitudes and longitudes (inverse). The
       results are accurate to round off for |f| < 1/50, where f is flatten‐
       ing.
...
       -p This option causes the azimuthal values to be output as unsigned
              DMS numbers between 0 and 360 degrees. Also note -f.

```

Thanks a lot anyway for reminding that `geod` exists and does its thing.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 5, 2025, 2:58pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/13 "2025-07-05T14:58:30Z")

</div>

> [@mkononets](#):
>
> CLI `geod` apparently reports the same, _forward and back azimuths and distance between_

Not exactly. It says _and back azimuths_, whilst on GMT.jl they are both _forward_, but _backwards_ are also possible if `backward=true` is set.

```auto
dist, az1, az2 = invgeod(lonlat1::Vector{<:Real}, lonlat2::Vector{<:Real}; proj::String="",
                         s_srs::String="", epsg::Integer=0, backward=false)

```

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 5, 2025, 3:17pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/14 "2025-07-05T15:17:23Z")

</div>

Fixes submitted in [mapproject -A does not respect ellipsoidal request · Issue #8759 · GenericMappingTools/gmt · GitHub](https://github.com/GenericMappingTools/gmt/issues/8759)

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [July 5, 2025, 3:36pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/15 "2025-07-05T15:36:48Z")

</div>

one more question about `gmt spatial` vs `geod`:

> [@Joaquim](#):
>
> ```auto
> julia> geod([-104.888, -4.559], 61.47443481564943, 1389.3356054500066/2)
> ([-104.88249997720496 -4.556000021167548], 61.47399778643971)
> 
> ```
> 
> second value is the azimuth at midpoint. The midpoint coordinates are a bit different of those by `gmtspatial`. Likely the reason is that `gmtspatial` is not able to compute centroids using the ellipsoidal coordinates.

```auto
gmt spatial -Qk tmp_line.gmt -je --FORMAT_FLOAT_OUT=%.17g
gmtspatial [WARNING]: Your distance mode (Great Circle) differs from your -j option (Geodesic) which takes precedence.
-104.88249999999999	-4.556	1.3893356053178714

```

Actually, for the centroid coordinates the difference is very small, see below.

longitude: `-104.88249999999999-(-104.88249997720496) = -0.00000002279503`  
latitude: `-4.556-(-4.556000021167548) = 0.000000021167548`  
that’s ~ 2.3e-8, the 8th decimal.  
With the distance `1.3893356053178714 - 1389.3356054500066/1000 = -0.0000000001321352`  
that’s 10th decimal digit if the distance is in km or 7th if in meters.

_ **Is the above not negligible?** _ Would be good to know sort of boundary when one needs to start investigating the discrepancies.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 5, 2025, 3:47pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/16 "2025-07-05T15:47:05Z")

</div>

Confess that I didn’t pay much attention to the `gmtspatial` case. Yes, those differences are negligible. For the centroid/midpoint I would expect that they are due to different methods used to compute it, but for the length I feel some tickles on why they don’t agree to more decimals as they are using (I think) the same equations, but nothing that I want to time in investigating.

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [July 5, 2025, 3:52pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/17 "2025-07-05T15:52:23Z")

</div>

Thanks anyway!

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [July 9, 2025, 8:13pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/18 "2025-07-09T20:13:27Z")

</div>

@Joaquim  
Sorry for bothering with this again, but I think `mapproject'`s `-W` option does not respect `-je` either.

I am not sure it is supposed to in this situation, but asking usually does not harm.

I tried to use `mapproject -Joa.../-Job... -We...` to calculate a rectangle of an oblique area, like it is shown on the figure in [`mapproject`’s documentation](https://docs.generic-mapping-tools.org/latest/mapproject.html#id1), left panel.

Here I am using the line from the topic, the ends and the calculated midpoint. The midpoint is needed for `-Joa/-Job...` specification. Then a rectangle 100 m (0.1 km) wide is specified as the oblique rectangular region around the line. Half-length is also needed for the correct `-R...` specification.

For this I am calling `mapproject` like below:

```auto
gmt mapproject -Job-104.88249997720496/-4.5560000211675495/-104.877/-4.553/3i -R0.69424861297385021/0.100+uk -We+n2 -je
255.112438522	-4.5597859581
255.1234276	-4.55379191313
255.12256147	-4.55221404886
255.111572409	-4.55820808067
255.112438522	-4.5597859581

gmt mapproject -Job-104.88249997720496/-4.5560000211675495/-104.877/-4.553/3i -R0.69424861297385021/0.100+uk -We+n2
255.112438522	-4.5597859581
255.1234276	-4.55379191313
255.12256147	-4.55221404886
255.111572409	-4.55820808067
255.112438522	-4.5597859581

```

^^^ output, i.e. rectangle coords with and without `-je` match. The same is true for the `-Joa...` case (not shown). For `mapproject -Joa...` I calculated azimuth externally, see more below.

My posting should have probably ended up here, but I could not just stop writing.

Another part of the same problem (I guess) was when I compared azimuth-based equator `-Joa... -We+n2` (using separate azimuth calculations `mapproject -A... -G...`) vs two-point-based equator `-Job... -We+n2`

When I used spherical azimuth from `mapproject -G... -A...` (without `-je`), the rectangles calculated using `mapproject -Joa... -We+n2` and `mapproject -Job... -We+n2`, matched. Please see Spaghetti 1 listing below.

When I used elliptical azimuth from `mapproject -G... -A...`, the resulting rectangles were visibly different. Please see Spaghetti 2 listing below.

Spaghetti 1, spherical `mapproject` azimuth, the two oblique rectangles match well:

```auto
geod +ellps=WGS84 -F %.17g -f %.17g +lat_1=-4.559 +lon_1=-104.888 +lat_2=-4.553 +lon_2=-104.877 +n_S=2
-4.5590000000000002	-104.88800000000001
-4.5560000211675495	-104.88249997720496
-4.5529999999999999	-104.877

gmt mapproject -G-104.88249997720496/-4.5560000211675495+uk -Af-104.88249997720496/-4.5560000211675495 --FORMAT_FLOAT_OUT=%.17g
-104.877	-4.5529999999999999	61.313245074112395	0.69424861297385021

#gmt mapproject Azimuth is 61.313245074112395, LENGTH_KM is 0.69424861297385021

gmt mapproject -Job-104.88249997720496/-4.5560000211675495/-104.877/-4.553/3i -R0.69424861297385021/0.100+uk -We+n2
255.112438522	-4.5597859581
255.1234276	-4.55379191313
255.12256147	-4.55221404886
255.111572409	-4.55820808067
255.112438522	-4.5597859581

gmt mapproject -Joa-104.88249997720496/-4.5560000211675495/61.313245074112395/3i -R0.69424861297385021/0.100+uk -We+n2
255.112438522	-4.5597859581
255.1234276	-4.55379191307
255.12256147	-4.5522140488
255.111572409	-4.55820808067
255.112438522	-4.5597859581

```

^^^ the two oblique rectangles match well

Spaghetti 2, the elliptical azimuth using `mapproject -G... -A... -je`, the two oblique rectangles at the end do not match:

```auto
geod +ellps=WGS84 -F %.17g -f %.17g +lat_1=-4.559 +lon_1=-104.888 +lat_2=-4.553 +lon_2=-104.877 +n_S=2
-4.5590000000000002	-104.88800000000001
-4.5560000211675495	-104.88249997720496
-4.5529999999999999	-104.877

#LON_CENTER is -104.88249997720496, LAT_CENTER is -4.5560000211675495

gmt mapproject -G-104.88249997720496/-4.5560000211675495+uk -Af-104.88249997720496/-4.5560000211675495 --FORMAT_FLOAT_OUT=%.17g -je
mapproject [WARNING]: Your distance mode (Great Circle) differs from your -j option (Geodesic) which takes precedence.
mapproject [WARNING]: Your distance mode (Great Circle) differs from your -j option (Geodesic) which takes precedence.
-104.877	-4.5529999999999999	61.473997783466466	0.69466780265863348

#gmt mapproject Azimuth is 61.473997783466466, LENGTH_KM is 0.69466780265863348

# geod azimuth calculations for comparison
echo -4.5560000211675495 -104.88249997720496 -4.553 -104.877 | geod +ellps=WGS84 -F %.17g -f %.17g -I
61.473997786429415	-118.52643895208958	694.66780272511619

#geod Azimuth is 61.473997786429415, LENGTH_M is 694.66780272511619

gmt mapproject -Job-104.88249997720496/-4.5560000211675495/-104.877/-4.553/3i -R0.69466780265863348/0.100+uk -We+n2
255.112435205	-4.55978776767
255.123430918	-4.55379010348
255.122564788	-4.55221223922
255.111569091	-4.55820989024
255.112435205	-4.55978776767

gmt mapproject -Joa-104.88249997720496/-4.5560000211675495/61.473997783466466/3i -R0.69466780265863348/0.100+uk -We+n2
255.112424564	-4.5597735875
255.123437115	-4.55380669965
255.122575429	-4.55222641921
255.111562895	-4.55819329394
255.112424564	-4.5597735875

```

^^^ the two oblique rectangles at the end do not match

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [July 9, 2025, 11:57pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/19 "2025-07-09T23:57:28Z")

</div>

A very quick comment without having read your questions with the needed attention.  
I don’t think that Oblique Marcator projection have an ellipsoidal version. Only spherical. This would explain at least part of your equalities.

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [July 10, 2025, 1:33pm UTC](https://forum.generic-mapping-tools.org/t/midpoint-of-a-line/6018/20 "2025-07-10T13:33:26Z")

</div>

> [@Joaquim](#):
>
> I don’t think that Oblique Mercator projection have an ellipsoidal version. Only spherical.

That would explain everything I found, the fact that Oblique Mercator projection is only available as spherical. That is, only the spherical distances and azimuths produce the matching oblique rectangles using `mapproject ...-We+n2`.

Thanks again!
