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

intersect.sh 1.8 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  1. #!/usr/bin/env bash
  2. # Testing gmt spatial intersection
  3. ps=intersect.ps
  4. cat << EOF > A.txt
  5. 0 0
  6. 0.6 -0.3
  7. 1.3 0
  8. 1 0.9
  9. 0.8 0.2
  10. 0 1
  11. -0.3 0.7
  12. 0 0
  13. EOF
  14. cat << EOF > B.txt
  15. 0.3 0.3
  16. 1 0.6
  17. 1.5 0.3
  18. 1.4 1.1
  19. 0.7 1.2
  20. 0.1 1
  21. 0.3 0.3
  22. EOF
  23. # Cartesian
  24. # Find intersections between A and B
  25. R=-R-0.5/1.6/-0.5/1.5
  26. gmt psxy $R -Jx1.5i -P -Ba1g1 -BWSne A.txt -W3p,red -K -X0.75i > $ps
  27. gmt psxy $R -J -O B.txt -W3p,blue -K >> $ps
  28. gmt spatial A.txt B.txt -Ie | gmt psxy $R -Jx1.5i -O -K -Sc0.15i -W0.25p >> $ps
  29. # Truncate A given B
  30. gmt spatial A.txt -TB.txt | gmt psxy $R -Jx1.5i -O -K -W0.5p,green >> $ps
  31. # Clip A and B to a smaller region
  32. gmt psxy $R -J -O -K -Ba1g1 -BWSne+tCartesian -W0.25p,. [AB].txt -Y4i >> $ps
  33. gmt psxy $R -J -O -K -L -W0.5p,- << EOF >> $ps
  34. -0.2 -0.4
  35. 1.1 -0.4
  36. 1.1 0.9
  37. -0.2 0.9
  38. EOF
  39. # Do clipping and plot the clipped files
  40. gmt spatial A.txt -C -R-0.2/1.1/-0.4/0.9 | gmt psxy $R -Jx1.5i -O -K -W3p,red >> $ps
  41. gmt spatial B.txt -C -R-0.2/1.1/-0.4/0.9 | gmt psxy $R -Jx1.5i -O -K -W3p,blue >> $ps
  42. # Make geographic files and scale coordinates by 10
  43. gmt math -T A.txt 10 MUL = Ag.txt
  44. gmt math -T B.txt 10 MUL = Bg.txt
  45. # Geographic
  46. # Find intersections between Ag and Bg
  47. R=-R-5/16/-5/15
  48. gmt psxy $R -Jm0.15i -O -Ba5g5 -BWSne Ag.txt -W3p,red -K -Y-4i -X3.75i >> $ps
  49. gmt psxy $R -J -O Bg.txt -W3p,blue -K >> $ps
  50. gmt spatial Ag.txt Bg.txt -Ie -fg | gmt psxy $R -Jm0.15i -O -K -Sc0.15i -W0.25p >> $ps
  51. # Truncate Ag given Bg
  52. gmt spatial Ag.txt -TBg.txt -fg | gmt psxy $R -Jm0.15i -O -K -W0.5p,green >> $ps
  53. # Clip Ag and Bg to a smaller region
  54. gmt psxy $R -J -O -K -Ba5g5 -BWSne+tGeographic -W0.25p,. [AB]g.txt -Y4i >> $ps
  55. gmt psxy $R -J -O -K -L -W0.5p,- << EOF >> $ps
  56. -2 -4
  57. 11 -4
  58. 11 9
  59. -2 9
  60. EOF
  61. # Do clipping and plot the clipped files
  62. gmt spatial Ag.txt -C -R-2/11/-4/9 -fg | gmt psxy $R -Jm0.15i -O -K -W3p,red >> $ps
  63. gmt spatial Bg.txt -C -R-2/11/-4/9 -fg | gmt psxy $R -Jm0.15i -O -W3p,blue >> $ps
Tip!

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

Comments

Loading...