Geospatial Expressions¶
Ibis supports the following geospatial expression APIs
GeoSpatialValue
¶
Bases: NumericValue
Source code in ibis/expr/types/geospatial.py
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 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 |
|
Functions¶
area()
¶
Compute the area of a geospatial value.
Returns:
Type | Description |
---|---|
FloatingValue
|
The area of |
Source code in ibis/expr/types/geospatial.py
16 17 18 19 20 21 22 23 24 |
|
as_binary()
¶
Get the geometry as well-known bytes (WKB) without the SRID data.
Returns:
Type | Description |
---|---|
BinaryValue
|
Binary value |
Source code in ibis/expr/types/geospatial.py
26 27 28 29 30 31 32 33 34 |
|
as_ewkb()
¶
Get the geometry as well-known bytes (WKB) with the SRID data.
Returns:
Type | Description |
---|---|
BinaryValue
|
WKB value |
Source code in ibis/expr/types/geospatial.py
56 57 58 59 60 61 62 63 64 |
|
as_ewkt()
¶
Get the geometry as well-known text (WKT) with the SRID data.
Returns:
Type | Description |
---|---|
StringValue
|
String value |
Source code in ibis/expr/types/geospatial.py
36 37 38 39 40 41 42 43 44 |
|
as_text()
¶
Get the geometry as well-known text (WKT) without the SRID data.
Returns:
Type | Description |
---|---|
StringValue
|
String value |
Source code in ibis/expr/types/geospatial.py
46 47 48 49 50 51 52 53 54 |
|
azimuth(right)
¶
Return the angle in radians from the horizontal of the vector defined by the inputs.
Angle is computed clockwise from down-to-up on the clock: 12=0; 3=PI/2; 6=PI; 9=3PI/2.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
FloatingValue
|
azimuth |
Source code in ibis/expr/types/geospatial.py
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
|
buffer(radius)
¶
Return all points whose distance from this geometry is less than or equal to radius
.
Calculations are in the Spatial Reference System of this Geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius |
float | ir.FloatingValue
|
Floating expression |
required |
Returns:
Type | Description |
---|---|
GeoSpatialValue
|
Geometry expression |
Source code in ibis/expr/types/geospatial.py
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
|
centroid()
¶
Returns the centroid of the geometry.
Returns:
Type | Description |
---|---|
PointValue
|
The centroid |
Source code in ibis/expr/types/geospatial.py
556 557 558 559 560 561 562 563 564 |
|
contains(right)
¶
Check if the geometry contains the right
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
contains_properly(right)
¶
Check if the first geometry contains the second one.
Excludes common border points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether self contains right excluding border points. |
Source code in ibis/expr/types/geospatial.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
covered_by(right)
¶
Check if the first geometry is covered by the second one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
covers(right)
¶
Check if the first geometry covers the second one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
crosses(right)
¶
Check if the geometries have at least one interior point in common.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
d_fully_within(right, distance)
¶
Check if self
is entirely within distance
from right
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
distance |
ir.FloatingValue
|
Distance to check |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
d_within(right, distance)
¶
Check if self
is partially within distance
from right
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
distance |
ir.FloatingValue
|
Distance to check |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
difference(right)
¶
Return the difference of two geometries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
GeoSpatialValue
|
Difference of |
Source code in ibis/expr/types/geospatial.py
623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
|
disjoint(right)
¶
Check if the geometries have no points in common.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
distance(right)
¶
Compute the distance between two geospatial expressions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry or geography |
required |
Returns:
Type | Description |
---|---|
FloatingValue
|
Distance between |
Source code in ibis/expr/types/geospatial.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
end_point()
¶
Return the last point of a LINESTRING
geometry as a POINT
.
Return NULL
if the input parameter is not a LINESTRING
Returns:
Type | Description |
---|---|
PointValue
|
End point |
Source code in ibis/expr/types/geospatial.py
461 462 463 464 465 466 467 468 469 470 471 |
|
envelope()
¶
Returns a geometry representing the bounding box of self
.
Returns:
Type | Description |
---|---|
PolygonValue
|
A polygon |
Source code in ibis/expr/types/geospatial.py
566 567 568 569 570 571 572 573 574 |
|
geo_equals(right)
¶
Check if the geometries are equal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
geometry_n(n)
¶
Get the 1-based Nth geometry of a multi geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int | ir.IntegerValue
|
Nth geometry index |
required |
Returns:
Type | Description |
---|---|
GeoSpatialValue
|
Geometry value |
Source code in ibis/expr/types/geospatial.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
geometry_type()
¶
Get the type of a geometry.
Returns:
Type | Description |
---|---|
StringValue
|
String representing the type of |
Source code in ibis/expr/types/geospatial.py
230 231 232 233 234 235 236 237 238 |
|
intersection(right)
¶
Return the intersection of two geometries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
GeoSpatialValue
|
Intersection of |
Source code in ibis/expr/types/geospatial.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 |
|
intersects(right)
¶
Check if the geometries share any points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
is_valid()
¶
Check if the geometry is valid.
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
255 256 257 258 259 260 261 262 263 |
|
length()
¶
Compute the length of a geospatial expression.
Returns:
Type | Description |
---|---|
FloatingValue
|
Length of |
Source code in ibis/expr/types/geospatial.py
328 329 330 331 332 333 334 335 336 |
|
line_locate_point(right)
¶
Locate the distance a point falls along the length of a line.
Returns a float between zero and one representing the location of the closest point on the linestring to the given point, as a fraction of the total 2d line length.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
PointValue
|
Point geometry |
required |
Returns:
Type | Description |
---|---|
FloatingValue
|
Fraction of the total line length |
Source code in ibis/expr/types/geospatial.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 |
|
line_merge()
¶
Merge a MultiLineString
into a LineString
.
Returns a (set of) LineString(s) formed by sewing together the constituent line work of a MultiLineString. If a geometry other than a LineString or MultiLineString is given, this will return an empty geometry collection.
Returns:
Type | Description |
---|---|
GeoSpatialValue
|
Merged linestrings |
Source code in ibis/expr/types/geospatial.py
717 718 719 720 721 722 723 724 725 726 727 728 729 730 |
|
line_substring(start, end)
¶
Clip a substring from a LineString.
Returns a linestring that is a substring of the input one, starting and ending at the given fractions of the total 2d length. The second and third arguments are floating point values between zero and one. This only works with linestrings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start |
ir.FloatingValue
|
Start value |
required |
end |
ir.FloatingValue
|
End value |
required |
Returns:
Type | Description |
---|---|
LineStringValue
|
Clipped linestring |
Source code in ibis/expr/types/geospatial.py
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
|
max_distance(right)
¶
Returns the 2-dimensional max distance between two geometries in projected units.
If self
and right
are the same geometry the function will return
the distance between the two vertices most far from each other in that
geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
FloatingValue
|
Maximum distance |
Source code in ibis/expr/types/geospatial.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
n_points()
¶
Return the number of points in a geometry. Works for all geometries.
Returns:
Type | Description |
---|---|
IntegerValue
|
Number of points |
Source code in ibis/expr/types/geospatial.py
492 493 494 495 496 497 498 499 500 |
|
n_rings()
¶
Return the number of rings for polygons and multipolygons.
Outer rings are counted as well.
Returns:
Type | Description |
---|---|
IntegerValue
|
Number of rings |
Source code in ibis/expr/types/geospatial.py
502 503 504 505 506 507 508 509 510 511 512 |
|
ordering_equals(right)
¶
Check if two geometries are equal and have the same point ordering.
Returns true if the two geometries are equal and the coordinates are in the same order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether points and orderings are equal. |
Source code in ibis/expr/types/geospatial.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
overlaps(right)
¶
Check if the geometries share space, have the same dimension, and are not completely contained by each other.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Overlaps indicator |
Source code in ibis/expr/types/geospatial.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
perimeter()
¶
Compute the perimeter of a geospatial expression.
Returns:
Type | Description |
---|---|
FloatingValue
|
Perimeter of |
Source code in ibis/expr/types/geospatial.py
338 339 340 341 342 343 344 345 346 |
|
point_n(n)
¶
Return the Nth point in a single linestring in the geometry.
Negative values are counted backwards from the end of the LineString, so that -1 is the last point. Returns NULL if there is no linestring in the geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
ir.IntegerValue
|
Nth point index |
required |
Returns:
Type | Description |
---|---|
PointValue
|
Nth point in |
Source code in ibis/expr/types/geospatial.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
|
set_srid(srid)
¶
Set the spatial reference identifier for the ST_Geometry
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
srid |
ir.IntegerValue
|
SRID integer value |
required |
Returns:
Type | Description |
---|---|
GeoSpatialValue
|
|
Source code in ibis/expr/types/geospatial.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
|
simplify(tolerance, preserve_collapsed)
¶
Simplify a given geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolerance |
ir.FloatingValue
|
Tolerance |
required |
preserve_collapsed |
ir.BooleanValue
|
Whether to preserve collapsed geometries |
required |
Returns:
Type | Description |
---|---|
GeoSpatialValue
|
Simplified geometry |
Source code in ibis/expr/types/geospatial.py
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 |
|
srid()
¶
Return the spatial reference identifier for the ST_Geometry.
Returns:
Type | Description |
---|---|
IntegerValue
|
SRID |
Source code in ibis/expr/types/geospatial.py
514 515 516 517 518 519 520 521 522 |
|
start_point()
¶
Return the first point of a LINESTRING
geometry as a POINT
.
Return NULL
if the input parameter is not a LINESTRING
Returns:
Type | Description |
---|---|
PointValue
|
Start point |
Source code in ibis/expr/types/geospatial.py
449 450 451 452 453 454 455 456 457 458 459 |
|
touches(right)
¶
Check if the geometries have at least one point in common, but do not intersect.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether self and right are touching |
Source code in ibis/expr/types/geospatial.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
transform(srid)
¶
Transform a geometry into a new SRID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
srid |
ir.IntegerValue
|
Integer expression |
required |
Returns:
Type | Description |
---|---|
GeoSpatialValue
|
Transformed geometry |
Source code in ibis/expr/types/geospatial.py
659 660 661 662 663 664 665 666 667 668 669 670 671 672 |
|
union(right)
¶
Merge two geometries into a union geometry.
Returns the pointwise union of the two geometries. This corresponds to the non-aggregate version the PostGIS ST_Union.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
GeoSpatialValue
|
Union of geometries |
Source code in ibis/expr/types/geospatial.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
within(right)
¶
Check if the first geometry is completely inside of the second.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right |
GeoSpatialValue
|
Right geometry |
required |
Returns:
Type | Description |
---|---|
BooleanValue
|
Whether |
Source code in ibis/expr/types/geospatial.py
576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
|
x()
¶
Return the X coordinate of self
, or NULL if not available.
Input must be a point.
Returns:
Type | Description |
---|---|
FloatingValue
|
X coordinate of |
Source code in ibis/expr/types/geospatial.py
385 386 387 388 389 390 391 392 393 394 395 |
|
x_max()
¶
Return the X maxima of a geometry.
Returns:
Type | Description |
---|---|
FloatingValue
|
X maxima |
Source code in ibis/expr/types/geospatial.py
419 420 421 422 423 424 425 426 427 |
|
x_min()
¶
Return the X minima of a geometry.
Returns:
Type | Description |
---|---|
FloatingValue
|
X minima |
Source code in ibis/expr/types/geospatial.py
409 410 411 412 413 414 415 416 417 |
|
y()
¶
Return the Y coordinate of self
, or NULL if not available.
Input must be a point.
Returns:
Type | Description |
---|---|
FloatingValue
|
Y coordinate of |
Source code in ibis/expr/types/geospatial.py
397 398 399 400 401 402 403 404 405 406 407 |
|
y_max()
¶
Return the Y maxima of a geometry.
Returns:
Type | Description |
---|---|
FloatingValue
|
Y maxima |
Source code in ibis/expr/types/geospatial.py
439 440 441 442 443 444 445 446 447 |
|
y_min()
¶
Return the Y minima of a geometry.
Returns:
Type | Description |
---|---|
FloatingValue
|
Y minima |
Source code in ibis/expr/types/geospatial.py
429 430 431 432 433 434 435 436 437 |
|
GeoSpatialColumn
¶
Bases: NumericColumn
, GeoSpatialValue
Source code in ibis/expr/types/geospatial.py
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 |
|
Functions¶
unary_union()
¶
Aggregate a set of geometries into a union.
This corresponds to the aggregate version of the PostGIS ST_Union. We give it a different name (following the corresponding method in GeoPandas) to avoid name conflicts with the non-aggregate version.
Returns:
Type | Description |
---|---|
GeoSpatialScalar
|
Union of geometries |
Source code in ibis/expr/types/geospatial.py
740 741 742 743 744 745 746 747 748 749 750 751 752 |
|