GenericMappingTools / GenericMappingTools/gmt

gmt spatial -Sb stray lines / cartesian only? / gap bridging / buffer scaling

Open
#5,270 11 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
979
Forks
414
Avg merge
17h 26m
Merged PRs (30d)
54

Description

**Description of the problem**

See [this forum post](https://forum.generic-mapping-tools.org/t/how-to-use-gmt-spatial-sb-correctly/1725) for context.

* When calculating a buffer polygon around a line with `gmt spatial -Sb` occasional stray lines appear. See upper left and lower right.
* Buffer in N-S direction is larger than in E-W direction. Visible in all three examples. Maybe only works for cartesian data?
* Bridges gaps instead of following both sides of line. See lower right. Negative space on the inside of upper left rectangle missing
* In the example I tried to get a 10 nautical miles (NM) wide buffer using `-Sb10n` but this ended far outside of 10 NM. In the example `0.05n` is used. Scaling seems to be way off.

![buffer](https://user-images.githubusercontent.com/45796239/119874559-09dbe300-bf26-11eb-883a-09f3f99f54db.png)

**Full script that generated the error**

```
#!/usr/bin/env bash

echo "Using GMT version: $(gmt --version)"

cat > testline1.txt << EOF
>
7.8 50.4
7.8 50.6
8.1 50.6
8.1 50.4
7.8 50.4
EOF

cat > testline2.txt << EOF
>
8 50
9.5 50.5
EOF

cat > testline3.txt << EOF
>
9 49.6
9 50
9.8 50
9.8 49.8
9.4 49.8
9.4 49.6
EOF

gmt spatial testline1.txt -Sb0.05n > testline1_buffer.txt
gmt spatial testline2.txt -Sb0.05n > testline2_buffer.txt
gmt spatial testline3.txt -Sb0.05n > testline3_buffer.txt

gmt begin buffer png
gmt basemap -R007:30/010:00/49:30/50:50 \
-JL008:34:13.64/50:01:59.90/49:57/50:23/15c -B

gmt plot testline1.txt -W1p,green
gmt plot testline1_buffer.txt -W1p,red

gmt plot testline2.txt -W1p,green
gmt plot testline2_buffer.txt -W1p,red

gmt plot testline3.txt -W1p,green
gmt plot testline3_buffer.txt -W1p,red
gmt end show
```

**Actual outcome**

See above

**Expected outcome**

Joaquim did some Mirone Magic which comes close to the expected outcome
![joaquim](https://forum.generic-mapping-tools.org/uploads/default/original/2X/9/936987a8c2e975feb8ca72d62e5901d0d51122e8.png)

**System information**

* Operating system: 5.9.16-1-MANJARO x86_64 GNU/Linux
* GMT version (`gmt --version`): 6.2.0_43ff8ef_2021.05.25

Contributor guide

Open the contributing guide

Research direction

Reproduce the three cases with the supplied Bash script and testline1.txt, testline2.txt, and testline3.txt using `gmt spatial -Sb`. Inspect the implementation and output for stray lines, gap bridging, directional distortion, and incorrect nautical-mile scaling. Done means the generated buffer polygons follow both sides of each line and match the requested width without the reported artifacts.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, c
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.