| 2 | |
| 3 | Overview of the temporal algebra elements and concepts. |
| 4 | |
| 5 | == Temporal topology relations == |
| 6 | |
| 7 | |
| 8 | {{{ |
| 9 | equals A ------ |
| 10 | B ------ |
| 11 | |
| 12 | during A ---- |
| 13 | B ------ |
| 14 | |
| 15 | contains A ------ |
| 16 | B ---- |
| 17 | |
| 18 | starts A ---- |
| 19 | B ------ |
| 20 | |
| 21 | started A ------ |
| 22 | B ---- |
| 23 | |
| 24 | finishs A ---- |
| 25 | B ------ |
| 26 | |
| 27 | finished A ------ |
| 28 | B ---- |
| 29 | |
| 30 | precedes A ---- |
| 31 | B ---- |
| 32 | |
| 33 | follows A ---- |
| 34 | B ---- |
| 35 | |
| 36 | overlapped A ------ |
| 37 | B ------ |
| 38 | |
| 39 | overlaps A ------ |
| 40 | B ------ |
| 41 | |
| 42 | over booth overlaps and overlapped |
| 43 | }}} |
| 44 | The relations must be read A is related to B, like |
| 45 | - A equals B |
| 46 | - A is during B |
| 47 | - A contains B |
| 48 | |
| 49 | Topological relations must be specified in {} parentheses |
| 50 | |
| 51 | {{{ |
| 52 | A {equals} B |
| 53 | }}} |
| 54 | |
| 55 | Topological relations are always combined with other |
| 56 | temporal operators in the {} parentheses |
| 57 | |
| 58 | == Temporal operators == |
| 59 | |
| 60 | Temporal operators that work on time intervals |
| 61 | and instances of maps in space time datasets: |
| 62 | |
| 63 | '''Intersection & ''' |
| 64 | |
| 65 | Examples with time intervals a and b: |
| 66 | {{{ |
| 67 | c <- a & b |
| 68 | a ------ |
| 69 | b ---- |
| 70 | c ---- |
| 71 | |
| 72 | a ---- |
| 73 | b ---- |
| 74 | c -- |
| 75 | |
| 76 | a --- |
| 77 | b --- |
| 78 | c |
| 79 | }}} |
| 80 | '''Union |''' |
| 81 | |
| 82 | Examples with time intervals a and b: |
| 83 | {{{ |
| 84 | c <- a | b |
| 85 | a ------ |
| 86 | b ---- |
| 87 | c ------ |
| 88 | |
| 89 | a ---- |
| 90 | b ---- |
| 91 | c ------ |
| 92 | |
| 93 | a --- |
| 94 | b --- |
| 95 | c ------ |
| 96 | |
| 97 | a --- |
| 98 | b --- |
| 99 | c |
| 100 | }}} |
| 101 | '''Disjoint Union +''' |
| 102 | |
| 103 | Examples with time intervals a and b: |
| 104 | {{{ |
| 105 | c <- a + b |
| 106 | a ------ |
| 107 | b ---- |
| 108 | c ------ |
| 109 | |
| 110 | a ---- |
| 111 | b ---- |
| 112 | c ------ |
| 113 | |
| 114 | a --- |
| 115 | b --- |
| 116 | c ------ |
| 117 | |
| 118 | a --- |
| 119 | b --- |
| 120 | c ------- |
| 121 | |
| 122 | }}} |
| 123 | '''Left Reference =''' |
| 124 | |
| 125 | Examples with time intervals a and b: |
| 126 | {{{ |
| 127 | c <- a = b |
| 128 | a ------ |
| 129 | b ---- |
| 130 | c ------ |
| 131 | |
| 132 | a ---- |
| 133 | b ---- |
| 134 | c ---- |
| 135 | |
| 136 | a --- |
| 137 | b --- |
| 138 | c --- |
| 139 | |
| 140 | a --- |
| 141 | b --- |
| 142 | c --- |
| 143 | }}} |
| 144 | |
| 145 | The = operator ignores indexing operators for space |
| 146 | time datasets: A[i] |
| 147 | |
| 148 | |
| 149 | Temporal selection operators to select parts of |
| 150 | space time datasets: |
| 151 | |
| 152 | ''' Selection :'''[[BR]] |
| 153 | ''' Inverse selection !:''' |
| 154 | |
| 155 | Temporal operators have no precedence. |
| 156 | |
| 157 | Examples: |
| 158 | |
| 159 | * Select all maps from space time dataset A that |
| 160 | have equal time intervals with space time dataset B |
| 161 | and store them in space time datasets C. |
| 162 | |
| 163 | {{{ |
| 164 | C = A : B |
| 165 | C = A {:} B |
| 166 | C = A {=:} B |
| 167 | C = A {equals,:} B |
| 168 | C = A {equals,=:} B |
| 169 | }}} |
| 170 | |
| 171 | * Select all maps from space time dataset A that |
| 172 | have unequal time intervals with space time dataset B |
| 173 | and store them in space time datasets C. |
| 174 | |
| 175 | {{{ |
| 176 | C = A !: B |
| 177 | C = A {!:} B |
| 178 | C = A {=!:} B |
| 179 | C = A {equals,!:} B |
| 180 | C = A {equals,=!:} B |
| 181 | }}} |
| 182 | |
| 183 | * Select all maps from space time dataset A that |
| 184 | are during time intervals of space time dataset B |
| 185 | and store them in space time datasets C. Use |
| 186 | the time interval/instances of A in C. |
| 187 | |
| 188 | {{{ |
| 189 | C = A {during,:} B |
| 190 | C = A {during,=:} B |
| 191 | }}} |
| 192 | |
| 193 | * Select all maps from space time dataset A that |
| 194 | are during time intervals of space time dataset B |
| 195 | and store them in space time datasets C. The maps |
| 196 | in C will have different time intervals as A or B using the union operator. |
| 197 | Hence they are unions between time intervals of A and B. |
| 198 | |
| 199 | {{{ |
| 200 | C = A {during,|:} B |
| 201 | }}} |
| 202 | |
| 203 | * Select all maps from space time dataset A |
| 204 | that are during B and during C and during D. |
| 205 | Store the resulting list of maps using the timer intervals/instances |
| 206 | of A in E. |
| 207 | |
| 208 | {{{ |
| 209 | E = A {during,=:} B {during,=:} C {during,=:} D |
| 210 | }}} |
| 211 | |
| 212 | Operator number of maps in interval [[BR]] |
| 213 | '''Number of maps #''' |
| 214 | |
| 215 | Compute the number of maps from space time dataset B that are |
| 216 | during the time intervals of maps from space time dataset A. |
| 217 | {{{ |
| 218 | A{contains,#}B |
| 219 | }}} |
| 220 | This will return a list of integers (scalars) corresponding to the maps of |
| 221 | A that contain maps from B. |
| 222 | |
| 223 | |
| 224 | == Combination of temporal operators == |
| 225 | |
| 226 | {{{ |
| 227 | -------------- |
| 228 | | | : | !: | |
| 229 | |---|- --|-----| |
| 230 | | & | &: | &!: | |
| 231 | | | | |: | |!: | |
| 232 | | + | +: | +!: | |
| 233 | | = | =: | =!: | |
| 234 | -------------- |
| 235 | }}} |
| 236 | |
| 237 | |
| 238 | == Logical operators == |
| 239 | |
| 240 | {{{ |
| 241 | == equal |
| 242 | != not equal |
| 243 | > greater than |
| 244 | >= greater than or equal |
| 245 | < less than |
| 246 | <= less than or equal |
| 247 | && and |
| 248 | || or |
| 249 | |
| 250 | }}} |
| 251 | |
| 252 | == Temporal functions == |
| 253 | |
| 254 | Note a and b can either be space time datasets or expressions. |
| 255 | |
| 256 | {{{ |
| 257 | if decision option |
| 258 | if(x, a) a if x not 0 |
| 259 | if(x, a, b) a if x not 0, b otherwise |
| 260 | |
| 261 | buff_t(a, size) Buffer stds a with granule ("1 month" or 5) |
| 262 | tshift(a, size) Shift stds a with granule ("1 month" or 5) |
| 263 | tsnap(a) Snap time instances and intervals of stds a |
| 264 | |
| 265 | start_time() Start time as HH::MM:SS |
| 266 | start_date() Start date as yyyy-mm-DD |
| 267 | start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS |
| 268 | end_time() End time as HH:MM:SS |
| 269 | end_date() End date as yyyy-mm-DD |
| 270 | end_datetime() End datetime as yyyy-mm-DD HH:MM |
| 271 | |
| 272 | start_doy() Day of year (doy) from the start time [1 - 366] |
| 273 | start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1 |
| 274 | start_year() The year of the start time [0 - 9999] |
| 275 | start_month() The month of the start time [1 - 12] |
| 276 | start_week() Week of year of the start time [1 - 54] |
| 277 | start_day() Day of month from the start time [1 - 31] |
| 278 | start_hour() The hour of the start time [0 - 23] |
| 279 | start_minute() The minute of the start time [0 - 59] |
| 280 | start_second() The second of the start time [0 - 59] |
| 281 | end_doy() Day of year (doy) from the end time [1 - 366] |
| 282 | end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1 |
| 283 | end_year() The year of the end time [0 - 9999] |
| 284 | end_month() The month of the end time [1 - 12] |
| 285 | end_week() Week of year of the end time [1 - 54] |
| 286 | end_day() Day of month from the start time [1 - 31] |
| 287 | end_hour() The hour of the end time [0 - 23] |
| 288 | end_minute() The minute of the end time [0 - 59] |
| 289 | end_second() The second of the end time [0 - 59] |
| 290 | }}} |
| 291 | |
| 292 | Examples: |
| 293 | Select all maps from space time dataset A that have equal time stamps |
| 294 | with space time dataset B and C and are ealier that Jan. 1. 2005 and |
| 295 | store them in space time dataset D. |
| 296 | |
| 297 | {{{ |
| 298 | D = if(start_date() < "2005-01-01"), A{equals,=:}B{equals,=:}C) |
| 299 | }}} |
| 300 | |
| 301 | = Temporal Vector Algebra = |
| 302 | |
| 303 | Boolean vector operations: |
| 304 | |
| 305 | {{{ |
| 306 | AND & Intersection (v.overlay operator=and) |
| 307 | OR | Union (v.overlay operator=or) |
| 308 | DISJOINT OR + Disjoint union (v.patch) |
| 309 | XOR ^ Symmetric difference (v.overlay operator=xor) |
| 310 | NOT ~ Complement (v.overlay operator=not) |
| 311 | }}} |
| 312 | |
| 313 | Vector functions: |
| 314 | |
| 315 | {{{ |
| 316 | buff_p(a, size) Buffer the points of all maps from space time vector dataset a with size |
| 317 | buff_l(a, size) Buffer the lines of all maps from space time vector dataset a with size |
| 318 | buff_a(a, size) Buffer the areas of all maps from space time vector dataset a with size |
| 319 | }}} |
| 320 | |
| 321 | Examples: |
| 322 | |
| 323 | * Create an intersection between all maps of space time dataset |
| 324 | A and B that have equal time stamps. |
| 325 | |
| 326 | {{{ |
| 327 | C = A & B |
| 328 | C = A {&} B |
| 329 | C = A {=&} B |
| 330 | C = A {equals,=&} B |
| 331 | }}} |
| 332 | |
| 333 | |
| 334 | * Question: Meeting of two animals that occur when the distance between two sea elephants is less than 10 meters? |
| 335 | Space time vector dataset A and B contains the measured positions and time instances/intervals of two sea elephants. |
| 336 | The granularity of the space time vector datasets is 1h. We create a new space time vector dataset C that contains the |
| 337 | spatio-temporal intersections of the positions of the sea elephants. |
| 338 | |
| 339 | |
| 340 | {{{ |
| 341 | C = buff_p(buff_t(A, "2 hours"), 5) {over||equals,&&} buff_p(buff_t(B, "2 hours"), 5) |
| 342 | }}} |
| 343 | |
| 344 | == Combinations of temporal and vector operators == |
| 345 | |
| 346 | {{{ |
| 347 | --------------------------------------- |
| 348 | | | : | !: | & | | | ^ | ~ | + | |
| 349 | |---|----|-----|----|----|----|----|----| |
| 350 | | & | &: | &!: | && | &| | &^ | &~ | &+ | |
| 351 | | | | |: | |!: | |& | || | |^ | |~ | |+ | |
| 352 | | + | +: | +!: | +& | +| | +^ | +~ | ++ | |
| 353 | | = | =: | =!: | =& | =| | =^ | =~ | =+ | |
| 354 | --------------------------------------- |
| 355 | }}} |
| 356 | |
| 357 | = Temporal Raster Algebra = |
| 358 | |
| 359 | Arithmetic Operators: |
| 360 | |
| 361 | {{{ |
| 362 | Symbol description precedence |
| 363 | |
| 364 | % modulus 1 |
| 365 | / division 1 |
| 366 | * multiplication 1 |
| 367 | + addition 2 |
| 368 | - subtraction 2 |
| 369 | }}} |
| 370 | |
| 371 | Logical operators: |
| 372 | |
| 373 | {{{ |
| 374 | Symbol description precedence |
| 375 | |
| 376 | == equal 3 |
| 377 | != not equal 3 |
| 378 | > greater than 3 |
| 379 | >= greater than or equal 3 |
| 380 | < less than 3 |
| 381 | <= less than or equal 3 |
| 382 | && and 4 |
| 383 | || or 4 |
| 384 | }}} |
| 385 | |
| 386 | Raster functions: |
| 387 | |
| 388 | {{{ |
| 389 | abs(x) return absolute value of x |
| 390 | foat(x) convert x to foating point |
| 391 | if decision options: |
| 392 | if(x) 1 if x not zero, 0 otherwise |
| 393 | if(x,a) a if x not zero, 0 otherwise |
| 394 | if(x,a,b) a if x not zero, b otherwise |
| 395 | int(x) convert x to integer [ truncates ] |
| 396 | log(x) natural log of x |
| 397 | log(x,b) log of x base b |
| 398 | max(x,y[,z...]) largest value of those listed |
| 399 | median(x,y[,z...]) median value of those listed |
| 400 | min(x,y[,z...]) smallest value of those listed |
| 401 | round(x) round x to nearest integer |
| 402 | sqrt(x) square root of x |
| 403 | tan(x) tangent of x (x is in degrees) |
| 404 | not(x) 1 if x is zero, 0 otherwise |
| 405 | pow(x,y) x to the power y |
| 406 | rand(a,b) random value x : a <= x < b |
| 407 | round(x) round x to nearest integer |
| 408 | sin(x) sine of x (x is in degrees) |
| 409 | sqrt(x) square root of x |
| 410 | tan(x) tangent of x (x is in degrees) |
| 411 | xor(x,y) exclusive-or (XOR) of x and y |
| 412 | isnull(x) check if x = NULL |
| 413 | }}} |
| 414 | |
| 415 | Internal variables: |
| 416 | |
| 417 | {{{ |
| 418 | row() current row of moving window |
| 419 | col() current col of moving window |
| 420 | x() current x-coordinate of moving window |
| 421 | y() current y-coordinate of moving window |
| 422 | ewres() current east-west resolution |
| 423 | nsres() current north-south resolution |
| 424 | null() NULL value |
| 425 | }}} |
| 426 | |
| 427 | Combination of temporal and arithmetical raster operators: |
| 428 | |
| 429 | {{{ |
| 430 | --------------------------------------- |
| 431 | | | : | !: | % | / | * | - | + | |
| 432 | |---|----|-----|----|----|----|----|----| |
| 433 | | & | &: | &!: | &% | &/ | &* | &- | &+ | |
| 434 | | | | |: | |!: | |% | |/ | |* | |- | |+ | |
| 435 | | + | +: | +!: | +% | +/ | +* | +- | ++ | |
| 436 | | = | =: | =!: | =% | =/ | =* | =- | =+ | |
| 437 | --------------------------------------- |
| 438 | }}} |
| 439 | |
| 440 | Combination of temporal and logical raster operators: |
| 441 | |
| 442 | {{{ |
| 443 | ------------------------------------------------ |
| 444 | | | : | !: | == | != | <= | >= | < | > | |
| 445 | |---|----|-----|-----|-----|-----|-----|----|----| |
| 446 | | & | &: | &!: | &== | &!= | &<= | &>= | &< | &> | |
| 447 | | | | |: | |!: | |== | |!= | |<= | |>= | |< | |> | |
| 448 | | + | +: | +!: | +== | +!= | +<= | +>= | +< | +> | |
| 449 | | = | =: | =!: | === | =!= | =<= | =>= | =< | => | |
| 450 | ------------------------------------------- ---- |
| 451 | }}} |
| 452 | |
| 453 | Note the combination of temporal and logical operators is only |
| 454 | possible in reference time mode. |
| 455 | |
| 456 | |
| 457 | |