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

snyder.sh 11 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
  1. #!/usr/bin/env bash
  2. #
  3. # Testing GMT gmt mapproject on examples in Snyder.
  4. #
  5. #
  6. # usage: snyder.sh
  7. #
  8. # script will report trouble if we do not match Snyder (+- 360 degrees for longitudes)
  9. # Slop is 0.11 m for gmt projected values
  10. blabber () {
  11. gf=($(echo "${sf[*]}" | gmt mapproject $* -F -C))
  12. gi=($(echo "${gf[*]}" | gmt mapproject $* -F -C -I --FORMAT_FLOAT_OUT=%lg))
  13. echo "${sf[*]} ${gi[*]} ${si[*]} ${gf[*]} $p" | $AWK -f test.awk
  14. }
  15. cat << EOF > test.awk
  16. #!/bin/awk -f
  17. {
  18. true_lon = \$1
  19. true_lat = \$2
  20. GMT_lon = \$3
  21. GMT_lat = \$4
  22. true_x = \$5
  23. true_y = \$6
  24. GMT_x = \$7
  25. GMT_y = \$8
  26. # Check longitudes & latitudes
  27. dx = GMT_lon - true_lon
  28. dy = GMT_lat - true_lat
  29. if (dy < 0.0) dy = -dy;
  30. if (dx < 0.0) dx = -dx;
  31. if (dx > 350) dx -= 360.0;
  32. if (! (dx == 0.0 || dx == -360.0 || dx = 360.0)) {
  33. printf "%s: Bad longitude conversion, d = %lg\n", \$9, dx
  34. }
  35. if (! (dy == 0.0)) {
  36. printf "%s: Bad latitude conversion, d = %lg\n", \$9, dy
  37. }
  38. # Check x & y
  39. dx = GMT_x - true_x
  40. dy = GMT_y - true_y
  41. if (dy < 0.0) dy = -dy;
  42. if (dx < 0.0) dx = -dx;
  43. if (! (dx <= 0.11)) {
  44. printf "%s: Bad x conversion, d = %lg\n", \$9, dx
  45. }
  46. if (! (dy <= 0.11)) {
  47. printf "%s: Bad y conversion, d = %lg\n", \$9, dy
  48. }
  49. }
  50. EOF
  51. gmt set PROJ_SCALE_FACTOR 1
  52. # Make ellipsoids (spheres) of radius 1 and 3:
  53. unit=1.0
  54. three=3.0
  55. # Make special Clarke-1866 ellipsoid using Snyders value for e^2=0.00676866
  56. # which gives 1/f = 294.97861076:
  57. snyder=6378206.4,294.97861076
  58. # International 1924 ellipsoid
  59. int=International-1924
  60. #----------------------------------------------------------------------------
  61. # Mercator, Spherical
  62. sf=(-75 35)
  63. si=(1.8325957 0.6528366)
  64. p="Mercator(Spherical)"
  65. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R0/360/-50/50 -Jm180/0/1:1 > fail
  66. #----------------------------------------------------------------------------
  67. #----------------------------------------------------------------------------
  68. # Mercator, Ellipsoidal
  69. sf=(-75 35)
  70. si=(11688673.7 4139145.6)
  71. p="Mercator(Ellipsoidal)"
  72. blabber --PROJ_ELLIPSOID=$snyder --FORMAT_FLOAT_OUT=%9.1lf -R0/360/-50/50 -Jm180/0/1:1 >> fail
  73. #----------------------------------------------------------------------------
  74. #----------------------------------------------------------------------------
  75. # Transverse Mercator, Spherical
  76. sf=(-73.5 40.5)
  77. si=(0.0199077 0.7070276)
  78. p="TM(Spherical)"
  79. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R-77/-72/35/45 -Jt-75/0/1:1 >> fail
  80. #----------------------------------------------------------------------------
  81. #----------------------------------------------------------------------------
  82. # Oblique Mercator, Spherical
  83. # Commented out since GMT and Snyder use different origins...
  84. #
  85. #sf=(120 -30)
  86. #si=(-2.4201335 -0.0474026)
  87. #p="Oblique-Mercator(Spherical)"
  88. #blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R0/360/-80/80 -Job0/45/-90/0/1:1 >> fail
  89. #----------------------------------------------------------------------------
  90. #----------------------------------------------------------------------------
  91. # Cylindrical Equal-Area, Spherical
  92. sf=(80 35)
  93. si=(2.3428242 0.6623090)
  94. p="Cylindrical-Equal-Area(Spherical)"
  95. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R-255/105/-80/80 -Jy-75/30/1:1 >> fail
  96. #----------------------------------------------------------------------------
  97. #----------------------------------------------------------------------------
  98. # Cylindrical Equal-Area, Ellipsoidal
  99. sf=(-78 5)
  100. si=(-332699.8 554248.5)
  101. p="Cylindrical-Equal-Area(Ellipsoidal)"
  102. blabber --PROJ_ELLIPSOID=$snyder --PROJ_SCALE_FACTOR=0.9996 --FORMAT_FLOAT_OUT=%9.1lf -R-255/105/-80/80 -Jy-75/5/1:1 >> fail
  103. #----------------------------------------------------------------------------
  104. #----------------------------------------------------------------------------
  105. # Miller, Spherical
  106. sf=(-75 50)
  107. si=(-1.3089969 0.9536371)
  108. p="Miller(Spherical)"
  109. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R-180/180/-80/80 -Jj0/1:1 >> fail
  110. #----------------------------------------------------------------------------
  111. #----------------------------------------------------------------------------
  112. # Cassini, Spherical
  113. sf=(-90 25)
  114. si=(-0.2367759 0.7988243)
  115. p="Cassini(Spherical)"
  116. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R-77/-73/-23/-17 -Jc-75/-20/1:1 >> fail
  117. #----------------------------------------------------------------------------
  118. #----------------------------------------------------------------------------
  119. # Cassini, Ellipsoidal
  120. sf=(-73 43)
  121. si=(163071.1 335127.6)
  122. p="Cassini(Ellipsoidal)"
  123. blabber --PROJ_ELLIPSOID=$snyder --FORMAT_FLOAT_OUT=%9.1lf -R-76/-72/38/42 -Jc-75/40/1:1 >> fail
  124. #----------------------------------------------------------------------------
  125. #----------------------------------------------------------------------------
  126. # Albers, Spherical
  127. sf=(-75 35)
  128. si=(0.2952720 0.2416774)
  129. p="Albers(Spherical)"
  130. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R-100/-90/30/40 -Jb-96/23/29.5/45.5/1:1 >> fail
  131. #----------------------------------------------------------------------------
  132. #----------------------------------------------------------------------------
  133. # Albers, Ellipsoidal
  134. sf=(-75 35)
  135. si=(1885472.7 1535925.0)
  136. p="Albers(Ellipsoidal)"
  137. blabber --PROJ_ELLIPSOID=$snyder --FORMAT_FLOAT_OUT=%9.1lf -R-100/-90/30/40 -Jb-96/23/29.5/45.5/1:1 >> fail
  138. #----------------------------------------------------------------------------
  139. #----------------------------------------------------------------------------
  140. # Lambert Conic, Spherical
  141. sf=(-75 35)
  142. si=(0.2966785 0.2462112)
  143. p="Lambert-Conic(Spherical)"
  144. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R-100/-90/30/40 -Jl-96/23/33/45/1:1 >> fail
  145. #----------------------------------------------------------------------------
  146. #----------------------------------------------------------------------------
  147. # Lambert Conic, Ellipsoidal
  148. sf=(-75 35)
  149. si=(1894410.9 1564649.5)
  150. p="Lambert-Conic(Ellipsoidal)"
  151. blabber --PROJ_ELLIPSOID=$snyder --FORMAT_FLOAT_OUT=%9.1lf -R-100/-90/30/40 -Jl-96/23/33/45/1:1 >> fail
  152. #----------------------------------------------------------------------------
  153. #----------------------------------------------------------------------------
  154. # Equidistant Conic, Spherical
  155. sf=(-75 35)
  156. si=(0.2952057 0.2424021)
  157. p="Equidistant-Conic(Spherical)"
  158. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R-100/-90/30/40 -Jd-96/23/29.5/45.5/1:1 >> fail
  159. #----------------------------------------------------------------------------
  160. #----------------------------------------------------------------------------
  161. # Stereographic, Spherical
  162. sf=(-75 30)
  163. si=(0.3807224 -0.1263802)
  164. p="Stereographic(Spherical)"
  165. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R0/360/-90/90 -Js-100/40/1:1 >> fail
  166. #----------------------------------------------------------------------------
  167. #----------------------------------------------------------------------------
  168. # Stereographic, Ellipsoidal
  169. sf=(-90 30)
  170. si=(971630.8 -1063049.3)
  171. p="Stereographic-General(Ellipsoidal)"
  172. blabber --PROJ_ELLIPSOID=$snyder --PROJ_SCALE_FACTOR=0.9999 --FORMAT_FLOAT_OUT=%9.1lf -R0/360/-90/90 -Js-100/40/1:1 >> fail
  173. #----------------------------------------------------------------------------
  174. #----------------------------------------------------------------------------
  175. # Stereographic, Ellipsoidal
  176. sf=(150 -75)
  177. si=(-1573645.4 -572760.1)
  178. p="Stereographic-Polar(Ellipsoidal)"
  179. blabber --PROJ_ELLIPSOID=$int --PROJ_SCALE_FACTOR=0.994 --FORMAT_FLOAT_OUT=%9.1lf -R0/360/-90/0 -Js-100/-90/1:1 >> fail
  180. #----------------------------------------------------------------------------
  181. #----------------------------------------------------------------------------
  182. # Gnomonic, Spherical
  183. sf=(-110 30)
  184. si=(-0.1542826 -0.1694739)
  185. p="Gnomonic(Spherical)"
  186. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R0/360/-90/90 -Jf-100/40/60/1:1 >> fail
  187. #----------------------------------------------------------------------------
  188. #----------------------------------------------------------------------------
  189. # Lambert Azim, Spherical
  190. sf=(100 -20)
  191. si=(-4.2339303 4.0257775)
  192. p="Lambert-Azimuthal(Spherical)"
  193. blabber --PROJ_ELLIPSOID=$three --FORMAT_FLOAT_OUT=%9.7lf -R0/360/-90/90 -Ja-100/40/180/1:1 >> fail
  194. #----------------------------------------------------------------------------
  195. #----------------------------------------------------------------------------
  196. # Lambert Azim, Ellipsoidal Polar
  197. sf=(5 80)
  198. si=(1077459.7 288704.5)
  199. p="Lambert-Azimuthal-Polar(Ellipsoidal)"
  200. blabber --PROJ_ELLIPSOID=$int --FORMAT_FLOAT_OUT=%9.1lf -R0/360/0/90 -Ja-100/90/1:1 >> fail
  201. #----------------------------------------------------------------------------
  202. #----------------------------------------------------------------------------
  203. # Lambert Azim, Ellipsoidal
  204. sf=(-110 30)
  205. si=(-965932.1 -1056814.9)
  206. p="Lambert-Azimuthal-General(Ellipsoidal)"
  207. blabber --PROJ_ELLIPSOID=$snyder --FORMAT_FLOAT_OUT=%9.1lf -R0/360/-90/90 -Ja-100/40/1:1 >> fail
  208. #----------------------------------------------------------------------------
  209. #----------------------------------------------------------------------------
  210. # Azim Equidistant, Spherical
  211. sf=(100 -20)
  212. si=(-5.8311398 5.5444634)
  213. p="Azimuthal-Equidistant(Spherical)"
  214. blabber --PROJ_ELLIPSOID=$three --FORMAT_FLOAT_OUT=%9.7lf -R0/360/-90/90 -Je-100/40/1:1 >> fail
  215. #----------------------------------------------------------------------------
  216. #----------------------------------------------------------------------------
  217. # Van der Grinten, Spherical
  218. sf=(-160 -50)
  219. si=(-1.1954154 -0.9960733)
  220. p="Van-der-Grinten(Spherical)"
  221. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R95/455/-90/90 -Jv-85/1:1 >> fail
  222. #----------------------------------------------------------------------------
  223. #----------------------------------------------------------------------------
  224. # Sinusoidal, Spherical
  225. sf=(-75 -50)
  226. si=(0.1682814 -0.8726646)
  227. p="Sinusoidal(Spherical)"
  228. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R90/450/-90/90 -Ji-90/1:1 >> fail
  229. #----------------------------------------------------------------------------
  230. #----------------------------------------------------------------------------
  231. # Mollweide, Spherical
  232. sf=(-75 -50)
  233. si=(0.1788845 -0.9208758)
  234. p="Mollweide(Spherical)"
  235. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R90/450/-90/90 -Jw-90/1:1 >> fail
  236. #----------------------------------------------------------------------------
  237. #----------------------------------------------------------------------------
  238. # Eckert IV, Spherical
  239. sf=(-75 -50)
  240. si=(0.1875270 -0.9519210)
  241. p="Eckert-IV(Spherical)"
  242. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R90/450/-90/90 -Jkf-90/1:1 >> fail
  243. #----------------------------------------------------------------------------
  244. #----------------------------------------------------------------------------
  245. # Eckert VI, Spherical
  246. sf=(-75 -50)
  247. si=(0.1693623 -0.9570223)
  248. p="Eckert-VI(Spherical)"
  249. blabber --PROJ_ELLIPSOID=$unit --FORMAT_FLOAT_OUT=%9.7lf -R90/450/-90/90 -Jks-90/1:1 >> fail
  250. #----------------------------------------------------------------------------
Tip!

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

Comments

Loading...