# Plot -A and output

**URL:** <https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591>\
**Category:** Q&A\
**Created:** [February 3, 2022, 1:41pm UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591 "2022-02-03T13:41:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [February 3, 2022, 1:41pm UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/1 "2022-02-03T13:41:55Z")

</div>

If I have a file with coordinates, I can plot it with `gmt plot -Ap [..]` to have it plot _following a parallel, then a meridian_ ([plot docs](https://docs.generic-mapping-tools.org/dev/plot.html#a)).

- I would like to use this `plot`-processed data for further use; are there any tools in `gmt` that can create the output what `plot -Ap` plots…?

E.g. How can I get the coordinates of the red lines from the figure created with the script below?

```auto
cat<<eof > test1.gmt
>
376056 7911283
404413 7927573
441218 7924556
461128 7889562
359766 7911283
376056 7911283
eof

# convert to lat long
gmt mapproject -F -C -I -Ju+32/1:1 test1.gmt > test.gmt

gmt begin blocky-line
  gmt plot test.gmt -Ap -Wthick,red -l"blocky (-Ap)"+jTL
  gmt plot -B0 test.gmt -l"original"
gmt end show

rm test1.gmt test.gmt gmt.history

```

---

<div class="post-metadata">

**Author:** ![PlanetGus](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/planetgus/32/303_2.png) [@PlanetGus](https://forum.generic-mapping-tools.org/u/PlanetGus)\
**Post date:** [February 3, 2022, 2:50pm UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/2 "2022-02-03T14:50:21Z")

</div>

Using grdtrack -Ap ?

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [February 3, 2022, 3:03pm UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/3 "2022-02-03T15:03:44Z")

</div>

Interesting. Will test.

---

<div class="post-metadata">

**Author:** ![PlanetGus](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/planetgus/32/303_2.png) [@PlanetGus](https://forum.generic-mapping-tools.org/u/PlanetGus)\
**Post date:** [February 3, 2022, 3:09pm UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/4 "2022-02-03T15:09:45Z")

</div>

If the “grd” part is not ideal I think you can use the -E option as a workaround to just input start/stop coordinates. Which would, I guess, fit your purpose

---

<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:** [February 3, 2022, 5:52pm UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/5 "2022-02-03T17:52:42Z")

</div>

Should work with sample1d -Ap -Isomemapincrement.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [February 3, 2022, 7:29pm UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/6 "2022-02-03T19:29:46Z")

</div>

> [@PlanetGus](#):
>
> grdtrack -Ap

Since I don’t have any grids, I’m not sure if `grdtrack` is the right tool.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [February 3, 2022, 7:34pm UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/7 "2022-02-03T19:34:58Z")

</div>

pwessel: `sample1d` looks like the thing, but I’m immediately bitten by the requirement to have a _monotonically increasing or decreasing_ variable. So the yak shaving starts. Any golden tips on how to resample points that are _arbitrarily_ sampled so I can use it with `sample1d`?

---

<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:** [February 4, 2022, 7:10am UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/8 "2022-02-04T07:10:23Z")

</div>

I think those terms only refers to time series. You are resampling an (lon,lat) line and the (guaranteed) monotonically increasing variable is the distance.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [February 4, 2022, 7:43am UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/9 "2022-02-04T07:43:32Z")

</div>

So this should work?

```auto
cat<<eof | gmt sample1d -Ap
5.53962564298 71.272033721
6.30984353357 71.4308039355
7.34727069584 71.4156247566
7.9243956509 71.1059801628
5.08609083753 71.2631386067
5.53962564298 71.272033721
eof
sample1d [ERROR]: x-values are not monotonically increasing/decreasing (at zero-based record 4)!
sample1d [ERROR]: Failure in gmt_intpol near row 5!

```

---

<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:** [February 4, 2022, 7:58am UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/10 "2022-02-04T07:58:43Z")

</div>

No, you need to use -I to give a sampling interval with a map distance unit, e.g. -I10k, to turn on spatial 2-D series resampling. Otherwise it is just a 1-D time series resampling.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [February 4, 2022, 8:23am UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/11 "2022-02-04T08:23:58Z")

</div>

I see. Thank you paul.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [February 4, 2022, 9:41am UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/12 "2022-02-04T09:41:23Z")

</div>

Seems to work nicely!

Two things:

- I got really confused since [sample1d docs](https://docs.generic-mapping-tools.org/dev/sample1d.html) does not mention `-I` as an option.
- Is there an easy way of ‘snapping’ (rounding down/up) the resampled coordinates to the nearest specified increment? E.g. snap to the nearest 15 arcseconds.

---

<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:** [February 4, 2022, 6:56pm UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/13 "2022-02-04T18:56:03Z")

</div>

Sorry, I get confused with our own deprecation rate at times. The -I was replaced with -T since we use -T for any 1-D array creation (gmt math, makecpt etc).

As for snapping: Probably not, but please give a short example of what you get and what you would like to get.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [February 4, 2022, 8:12pm UTC](https://forum.generic-mapping-tools.org/t/plot-a-and-output/2591/14 "2022-02-04T20:12:04Z")

</div>

Thanks again Paul. And sorry; I’m the one who should’ve studied the man page closer…

I’ll create an example of what I mean.

And… some other thing that turned up (and I’m confused)

- `gmt plot -Ap [..]` gives the same result as `sample1d -Am [..]`

- `gmt plot -Am [..]` gives the same result as `sample1d -Ap [..]`

- `-Am` for both (`plot` and `sample1d`): _follow meridian (along y) then parallel (along x)_

- `-Ap` for both: _[…] first follow parallel (along y) then meridian_

Should not `-Ap` and `-Am` do the same in these cases? Maybe these got flipped somehow.

Example of this (recycling code from first post):

```auto
cat<<eof > test1.gmt
>
376056 7911283
404413 7927573
441218 7924556
461128 7889562
359766 7911283
376056 7911283
eof

# convert to lat long
gmt mapproject -F -C -I -Ju+32/1:1 test1.gmt > test.gmt

gmt begin blocky-line
  gmt plot test.gmt -Ap -Wthick,red -l"plot -Ap"+jTL
  gmt plot test.gmt -l"original"
  gmt sample1d -T10k -Am test.gmt | gmt plot -B0 -l"sample1d -Am" -Wblue
gmt end show

rm test1.gmt test.gmt gmt.history

```
