Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

near_a_line.sh 1.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  1. #!/usr/bin/env bash
  2. #
  3. # Making sure both forms of "near a line" works:
  4. # Default (old) behavior is to think of a line as
  5. # a continuous trace of points; hence data points
  6. # within the given distance from the end points are
  7. # considered inside even if they gmt project to the
  8. # extension of the line segment.
  9. # Optional (new) behavior (-Lp) will only consider
  10. # points near the line if they gmt project inside the
  11. # line's endpoints
  12. ps=near_a_line.ps
  13. # Some test data
  14. gmt grdmath -R0/5/0/5 -I0.1 0 = tt.nc
  15. cat << EOF > tt.d
  16. > line 1
  17. 1 1
  18. 2 2.2
  19. 3 2.8
  20. 3.7 4
  21. EOF
  22. gmt grd2xyz tt.nc > tt.xyz
  23. # Do test both with Cartesian and spherical data
  24. # CARTESIAN DATA: distance D = 1 unit
  25. D=1
  26. # Old behavior
  27. gmt psxy -R0/5/0/5 -JX3.25i -P -K -Sc0.02 -Gred tt.xyz -X0.75i -Y1i > $ps
  28. gmt select tt.xyz -Ltt.d+d${D} | gmt psxy -R -J -O -K -B1g1 -BWSne -Sc0.02 -Ggreen >> $ps
  29. gmt psxy -R -J -O -K tt.d -W1p >> $ps
  30. # New behavior
  31. gmt psxy -R -J -O -K -Sc0.02 -Gred tt.xyz -X3.75i >> $ps
  32. gmt select tt.xyz -Ltt.d+d${D}+p | gmt psxy -R -J -O -K -B1g1 -BWSne -Sc0.02 -Ggreen >> $ps
  33. gmt psxy -R -J -O -K tt.d -W1p >> $ps
  34. # SPHERICAL DATA (-fg): distance D = 1 degree
  35. D=1d
  36. # Old behavior
  37. gmt psxy -R -JM3.25i -O -K -Sc0.02 -Gred tt.xyz -X-3.75i -Y4i >> $ps
  38. gmt select tt.xyz -Ltt.d+d${D} -fg | gmt psxy -R -J -O -K -B1g1 -BWSne -Sc0.02 -Ggreen >> $ps
  39. gmt psxy -R -J -O -K tt.d -W1p >> $ps
  40. # New behavior
  41. gmt psxy -R -J -O -K -Sc0.02 -Gred tt.xyz -X3.75i >> $ps
  42. gmt select tt.xyz -Ltt.d+d${D}+p -fg | gmt psxy -R -J -O -K -B1g1 -BWSne -Sc0.02 -Ggreen >> $ps
  43. gmt psxy -R -J -O tt.d -W1p >> $ps
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...