# How to create a 200m-wide rectangle around a cross-section line in GMT 6.3?

**URL:** https://forum.generic-mapping-tools.org/t/how-to-create-a-200m-wide-rectangle-around-a-cross-section-line-in-gmt-6-3/6034
**Category:** Q&A
**Tags:** gmt
**Created:** [July 4, 2025, 3:54am UTC](https://forum.generic-mapping-tools.org/t/how-to-create-a-200m-wide-rectangle-around-a-cross-section-line-in-gmt-6-3/6034 "2025-07-04T03:54:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![aqeel-magsi](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@aqeel-magsi](https://forum.generic-mapping-tools.org/u/aqeel-magsi)
#### Post date: [July 4, 2025, 3:54am UTC](https://forum.generic-mapping-tools.org/t/how-to-create-a-200m-wide-rectangle-around-a-cross-section-line-in-gmt-6-3/6034/1 "2025-07-04T03:54:39Z")

</div>

I’m trying to create a cross-section visualization similar to

 ![Reference image](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/1/1523ab7d447e83fb259b7e04906a72e2c0863812.jpeg)  
where I need to:

1. Draw a line between two geographic points (A: 104.475°E,29.40°N to B: 104.492°E,29.38°N)
2. Create a rectangle that extends 100 meters on each side of this line (total width 200m)

I know how to draw the basic line using:

> ```
> echo "104.475 29.40" > line.txt
> echo "104.492 29.38" >> line.txt
> gmt plot line.txt -W1.,black,--
> 
> ```

But I’m unsure how to:

1. Calculate the perpendicular offsets needed to create the rectangle
2. Ensure the width is exactly 200 meters in real-world dimensions
3. Close the polygon properly to form a rectangle

Would someone be able to provide a GMT 6.3 solution that creates this buffer around my line?

---

<div class="post-metadata">

### Author: ![ZMAlt](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/zmalt/32/4912_2.png) [@ZMAlt](https://forum.generic-mapping-tools.org/u/ZMAlt)
#### Post date: [July 6, 2025, 3:10am UTC](https://forum.generic-mapping-tools.org/t/how-to-create-a-200m-wide-rectangle-around-a-cross-section-line-in-gmt-6-3/6034/2 "2025-07-06T03:10:38Z")

</div>

Hi,  
There may be two ways.

1. use `gmtspatial -Sb` to get a buffer. However, the buffer is based on Cartesian coordinate, you may need to do projection before this. Or you can use `buffergeo` function in GMT.jl wchich supports Cartesian distance.
2. use `grdtrack -C` to get cross profiles and reshape them.
