Skip to content

Geospatial Expressions

Ibis supports the following geospatial expression APIs

geospatial

Classes

GeoSpatialColumn (NumericColumn, GeoSpatialValue)

Methods
unary_union(self)

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
ir.GeoSpatialScalar

Union of geometries

GeoSpatialValue (NumericValue)

Methods
area(self)

Compute the area of a geospatial value.

Returns:

Type Description
ir.FloatingValue

The area of self

as_binary(self)

Get the geometry as well-known bytes (WKB) without the SRID data.

Returns:

Type Description
ir.BinaryValue

Binary value

as_ewkb(self)

Get the geometry as well-known bytes (WKB) with the SRID data.

Returns:

Type Description
ir.BinaryValue

WKB value

as_ewkt(self)

Get the geometry as well-known text (WKT) with the SRID data.

Returns:

Type Description
ir.StringValue

String value

as_text(self)

Get the geometry as well-known text (WKT) without the SRID data.

Returns:

Type Description
ir.StringValue

String value

azimuth(self, right)

Return the angle in radians from the horizontal of the vector defined by

self and right.

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
ir.FloatingValue

azimuth

buffer(self, radius)

Returns a geometry that represents all points whose distance from this

Geometry is less than or equal to distance. 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

centroid(self)

Returns the centroid of the geometry.

Returns:

Type Description
PointValue

The centroid

contains(self, right)

Check if the geometry contains the right.

Parameters:

Name Type Description Default
right GeoSpatialValue

Right geometry

required

Returns:

Type Description
ir.BooleanValue

Whether self contains right

contains_properly(self, 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
ir.BooleanValue

Whether self contains right excluding border points.

covered_by(self, 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
ir.BooleanValue

Whether self is covered by right

covers(self, right)

Check if the first geometry covers the second one.

Parameters:

Name Type Description Default
right GeoSpatialValue

Right geometry

required

Returns:

Type Description
ir.BooleanValue

Whether self covers right

crosses(self, 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
ir.BooleanValue

Whether self and right have at least one common interior point.

d_fully_within(self, 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
ir.BooleanValue

Whether self is within a specified distance from right.

d_within(self, 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
ir.BooleanValue

Whether self is partially within distance from right.

difference(self, right)

Return the difference of two geometries.

Parameters:

Name Type Description Default
right GeoSpatialValue

Right geometry

required

Returns:

Type Description
GeoSpatialValue

Difference of self and right

disjoint(self, right)

Check if the geometries have no points in common.

Parameters:

Name Type Description Default
right GeoSpatialValue

Right geometry

required

Returns:

Type Description
ir.BooleanValue

Whether self and right are disjoint

distance(self, right)

Compute the distance between two geospatial expressions.

Parameters:

Name Type Description Default
right GeoSpatialValue

Right geometry or geography

required

Returns:

Type Description
ir.FloatingValue

Distance between self and right

end_point(self)

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

envelope(self)

Returns a geometry representing the bounding box of self.

Returns:

Type Description
ir.PolygonValue

A polygon

geo_equals(self, right)

Check if the geometries are equal.

Parameters:

Name Type Description Default
right GeoSpatialValue

Right geometry

required

Returns:

Type Description
ir.BooleanValue

Whether self equals right

geometry_n(self, 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

geometry_type(self)

Get the type of a geometry.

Returns:

Type Description
ir.StringValue

String representing the type of self.

intersection(self, right)

Return the intersection of two geometries.

Parameters:

Name Type Description Default
right GeoSpatialValue

Right geometry

required

Returns:

Type Description
GeoSpatialValue

Intersection of self and right

intersects(self, right)

Check if the geometries share any points.

Parameters:

Name Type Description Default
right GeoSpatialValue

Right geometry

required

Returns:

Type Description
ir.BooleanValue

Whether self intersects right

is_valid(self)

Check if the geometry is valid.

Returns:

Type Description
ir.BooleanValue

Whether self is valid

length(self)

Compute the length of a geospatial expression.

Returns:

Type Description
ir.FloatingValue

Length of self

line_locate_point(self, 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
ir.FloatingValue

Fraction of the total line length

line_merge(self)

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
ir.LineStringValue

Merged linestrings

line_substring(self, 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
ir.LineStringValue

Clipped linestring

max_distance(self, right)

Returns the 2-dimensional maximum 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
ir.FloatingValue

Maximum distance

n_points(self)

Return the number of points in a geometry. Works for all geometries

Returns:

Type Description
ir.IntegerValue

Number of points

n_rings(self)

Return the number of rings for polygons and multipolygons.

Outer rings are counted as well.

Returns:

Type Description
ir.IntegerValue

Number of rings

ordering_equals(self, 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
ir.BooleanValue

Whether points and orderings are equal.

overlaps(self, 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
ir.BooleanValue

Overlaps indicator

perimeter(self)

Compute the perimeter of a geospatial expression.

Returns:

Type Description
ir.FloatingValue

Perimeter of self

point_n(self, 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 self

set_srid(self, 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

self with SRID set to srid

simplify(self, 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

srid(self)

Return the spatial reference identifier for the ST_Geometry.

Returns:

Type Description
ir.IntegerValue

SRID

start_point(self)

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

touches(self, 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
ir.BooleanValue

Whether self and right are touching

transform(self, 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

union(self, 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

within(self, 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
ir.BooleanValue

Whether self is in right.

x(self)

Return the X coordinate of self, or NULL if not available.

Input must be a point.

Returns:

Type Description
ir.FloatingValue

X coordinate of self

x_max(self)

Return the X maxima of a geometry.

Returns:

Type Description
ir.FloatingValue

X maxima

x_min(self)

Return the X minima of a geometry.

Returns:

Type Description
ir.FloatingValue

X minima

y(self)

Return the Y coordinate of self, or NULL if not available.

Input must be a point.

Returns:

Type Description
ir.FloatingValue

Y coordinate of self

y_max(self)

Return the Y maxima of a geometry.

Returns:

Type Description
ir.FloatingValue

Y maxima

y_min(self)

Return the Y minima of a geometry.

Returns:

Type Description
ir.FloatingValue

Y minima


Last update: February 3, 2022