# How extend profile?

**URL:** <https://forum.generic-mapping-tools.org/t/how-extend-profile/2544>\
**Category:** Q&A\
**Created:** [January 22, 2022, 3:13am UTC](https://forum.generic-mapping-tools.org/t/how-extend-profile/2544 "2022-01-22T03:13:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [January 22, 2022, 3:13am UTC](https://forum.generic-mapping-tools.org/t/how-extend-profile/2544/1 "2022-01-22T03:13:44Z")

</div>

I have a profile (see below) that lengths ca. 15 km. and I want extend the profile that same distance in both direction. I.e. I want to add two extra points (at the beginning and the end following its azimuth) at a distance of 15 km (so the new profile would be 45 km).

I think it should be easy but I can’t figure out how to do it.

```
# Long Lat
-66.04971205	-55.14285297
-66.01518493	-55.11524701
-65.97886793	-55.08903702
-65.94340697	-55.06219498
-65.90790703	-55.03662696
```

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [January 22, 2022, 3:37am UTC](https://forum.generic-mapping-tools.org/t/how-extend-profile/2544/2 "2022-01-22T03:37:18Z")

</div>

Not sure about easy (i.e., scripting) but I would do this:

1. Run gmt mapproject **-Af** (or **-Ab** , cannot recall) on your data file to get the azimuths you need at either end.
2. Use gmt vector **-Tt** _azim_/15k to get your two points.

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [January 22, 2022, 4:00am UTC](https://forum.generic-mapping-tools.org/t/how-extend-profile/2544/3 "2022-01-22T04:00:58Z")

</div>

Ok, thanks.

And then I should make something like this to have a new profile, right?

```
gmt vector **-Tt** *azim*/15k > New_profile # new start point
gmt convert data.txt -o0,1 >> New_profile
gmt vector **-Tt** *azim*/15k >> New_profile # new end point
```

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [January 22, 2022, 4:55am UTC](https://forum.generic-mapping-tools.org/t/how-extend-profile/2544/4 "2022-01-22T04:55:24Z")

</div>

Yes, something like that if you need to script this for multiple use. So azim1 and azim2 then since they are likely different. And I am guessing -Ab for the first point (to get azimuth backward) and -Af for the last point. Maybe mapproject -Ab file | gmt convert -Ef to get first azim1 and map project -Af file | gmt convert -El to get the last azim.

---

<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:** [January 22, 2022, 7:42pm UTC](https://forum.generic-mapping-tools.org/t/how-extend-profile/2544/5 "2022-01-22T19:42:52Z")

</div>

And the solution is

```auto
# az2 is the forward azim at point2
julia> d, az1, az2 = invgeod([-66.04971205 -55.14285297], [-65.90790703 -55.03662696])
([14893.888506208705], [37.49803389341683], [37.381746701225865])

# Extend point 2 15 km along azim2
julia> geod([-65.90790703 -55.03662696], 37.3817, 15000)
([-65.76584878309455 -54.92947611687853], 37.26535673380841)

# Same story but revert point1 & point2
julia> d, az1, az2 = invgeod([-65.90790703 -55.03662696], [-66.04971205 -55.14285297])
([14893.888506208705], [-142.61825329877414], [-142.50196610658315])

julia> geod([-66.04971205 -55.14285297], -142.50197, 15000)
([-66.19329013066837 -55.24966629463536], -142.38407625074115)

```

or

```auto
-66.19329013066837 -55.24966629463536
-66.04971205 -55.14285297
-65.90790703 -55.03662696
-65.76584878309455 -54.92947611687853

```

```auto
extended=[-66.19329013 -55.249666294635; -66.04971205 -55.14285297; -65.90790703 -55.03662696; -65.765848783 -54.929476117];
imshow(extended, lc=:blue, marker=:circ, mc=:red)

```

 ![GMTjl_tmp](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/2/29a1fa7b7ce3adb96ca06383e48e47464bbf1024.png)

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [January 22, 2022, 8:33pm UTC](https://forum.generic-mapping-tools.org/t/how-extend-profile/2544/6 "2022-01-22T20:33:18Z")

</div>

OK, but if it is an important thing to do then I could implement gmt spatial -L15k and that would be even shorter and accessible to all wrappers.

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [January 22, 2022, 9:33pm UTC](https://forum.generic-mapping-tools.org/t/how-extend-profile/2544/7 "2022-01-22T21:33:14Z")

</div>

Yes, thanks I will definitively used it.

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [January 27, 2022, 8:25pm UTC](https://forum.generic-mapping-tools.org/t/how-extend-profile/2544/8 "2022-01-27T20:25:24Z")

</div>

For the record.  
A new feature was added in GMT 6.4: `gmt spatial -W`.
