Generate a repeating sequence of longitude and latitude coordinates based on a period of rotation.
get_lonlat_seq(lon, lat, n.period = 360, n.frames = n.period)
lon | vector of arbitrary longitudes or starting longitude (starting point for constant globe rotation). |
---|---|
lat | vector of arbitrary latitudes or fixed, repeating latitude. |
n.period | intended length of the period. |
n.frames | intended number of frames in animation. |
returns a list containing a longitude vector and a latitude vector.
lon
and lat
may be scalars or vectors. If scalar, lat
is simply repeated n.frames
times.
If scalar, lon
is always treated as a starting longitude and a rotational sequence of longitudes is beginning from lon
is generated for a length equal to n.frames
, repeating the sequence if necessary.
If lon
or lat
are vectors, it is assumed that predefined custom sequences of longitude and latitude have been provided,
so they are required to be of length n.period
.
However long it takes to iterate through the custom coordinates sequence ought to define the period.
It also makes sense in this case for n.frames
to remain equal to n.period
if the custom sequence is not meant to be cyclical but rather a single pass.
After this check the custom vectors are simply bound in a list.
# default 360 frames of 360-length period rotation, get_lonlat_seq(0, 0) # beginning from lon 0, at lat 0#> $lon #> [1] 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 #> [16] -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 #> [31] -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 #> [46] -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 #> [61] -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 #> [76] -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 #> [91] -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 #> [106] -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 #> [121] -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 #> [136] -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 #> [151] -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 #> [166] -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 #> [181] 180 179 178 177 176 175 174 173 172 171 170 169 168 167 166 #> [196] 165 164 163 162 161 160 159 158 157 156 155 154 153 152 151 #> [211] 150 149 148 147 146 145 144 143 142 141 140 139 138 137 136 #> [226] 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 #> [241] 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 #> [256] 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 #> [271] 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 #> [286] 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 #> [301] 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 #> [316] 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 #> [331] 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 #> [346] 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 #> #> $lat #> [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [112] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [149] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [186] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [223] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [260] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [297] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [334] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #>get_lonlat_seq(0, 0, n.frames=40) # same but only first 40 frames#> $lon #> [1] 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 #> [20] -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 #> [39] -38 -39 #> #> $lat #> [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [39] 0 0 #>get_lonlat_seq(0, 0, n.frames=400) # same but looping for 40 additional frames#> $lon #> [1] 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 #> [16] -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 #> [31] -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 #> [46] -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 #> [61] -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 #> [76] -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 #> [91] -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103 -104 #> [106] -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 #> [121] -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 #> [136] -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149 #> [151] -150 -151 -152 -153 -154 -155 -156 -157 -158 -159 -160 -161 -162 -163 -164 #> [166] -165 -166 -167 -168 -169 -170 -171 -172 -173 -174 -175 -176 -177 -178 -179 #> [181] 180 179 178 177 176 175 174 173 172 171 170 169 168 167 166 #> [196] 165 164 163 162 161 160 159 158 157 156 155 154 153 152 151 #> [211] 150 149 148 147 146 145 144 143 142 141 140 139 138 137 136 #> [226] 135 134 133 132 131 130 129 128 127 126 125 124 123 122 121 #> [241] 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 #> [256] 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 #> [271] 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 #> [286] 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 #> [301] 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 #> [316] 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 #> [331] 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 #> [346] 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 #> [361] 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 #> [376] -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 #> [391] -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 #> #> $lat #> [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [112] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [149] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [186] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [223] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [260] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [297] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [334] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [371] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #>get_lonlat_seq(-20, 30, n.period=60) # quicker period, begin from lon -20, at lat 30#> $lon #> [1] -20 -26 -32 -38 -44 -50 -56 -62 -68 -74 -80 -86 -92 -98 -104 #> [16] -110 -116 -122 -128 -134 -140 -146 -152 -158 -164 -170 -176 178 172 166 #> [31] 160 154 148 142 136 130 124 118 112 106 100 94 88 82 76 #> [46] 70 64 58 52 46 40 34 28 22 16 10 4 -2 -8 -14 #> #> $lat #> [1] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 #> [26] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 #> [51] 30 30 30 30 30 30 30 30 30 30 #>get_lonlat_seq(1:60, 2:61, n.period=60) # custom sequence is simply put in list#> $lon #> [1] 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] 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] 51 52 53 54 55 56 57 58 59 60 #> #> $lat #> [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 #> [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 #> [51] 52 53 54 55 56 57 58 59 60 61 #>