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

GeoSpatialScalar Union of geometries

GeoSpatialValue (NumericValue)

Methods
area(self)

Compute the area of a geospatial value.

Returns

FloatingValue The area of self

as_binary(self)

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

Returns

BinaryValue Binary value

as_ewkb(self)

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

Returns

BinaryValue WKB value

as_ewkt(self)

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

Returns

StringValue String value

as_text(self)

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

Returns

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

right Right geometry

Returns

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

radius Floating expression

Returns

GeoSpatialValue Geometry expression

centroid(self)

Returns the centroid of the geometry.

Returns

PointValue The centroid

contains(self, right)

Check if the geometry contains the right.

Parameters

right Right geometry

Returns

BooleanValue Whether self contains right

contains_properly(self, right)

Check if the first geometry contains the second one.

Excludes common border points.

Parameters

right Right geometry

Returns

BooleanValue Whether self contains right excluding border points.

covered_by(self, right)

Check if the first geometry is covered by the second one.

Parameters

right Right geometry

Returns

BooleanValue Whether self is covered by right

covers(self, right)

Check if the first geometry covers the second one.

Parameters

right Right geometry

Returns

BooleanValue Whether self covers right

crosses(self, right)

Check if the geometries have at least one interior point in common.

Parameters

right Right geometry

Returns

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

right Right geometry distance Distance to check

Returns

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

right Right geometry distance Distance to check

Returns

BooleanValue Whether self is partially within distance from right.

difference(self, right)

Return the difference of two geometries.

Parameters

right Right geometry

Returns

GeoSpatialValue Difference of self and right

disjoint(self, right)

Check if the geometries have no points in common.

Parameters

right Right geometry

Returns

BooleanValue Whether self and right are disjoint

distance(self, right)

Compute the distance between two geospatial expressions.

Parameters

right Right geometry or geography

Returns

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

PointValue End point

envelope(self)

Returns a geometry representing the bounding box of self.

Returns

PolygonValue A polygon

geo_equals(self, right)

Check if the geometries are equal.

Parameters

right Right geometry

Returns

BooleanValue Whether self equals right

geometry_n(self, n)

Get the 1-based Nth geometry of a multi geometry.

Parameters

n Nth geometry index

Returns

GeoSpatialValue Geometry value

geometry_type(self)

Get the type of a geometry.

Returns

StringValue String representing the type of self.

intersection(self, right)

Return the intersection of two geometries.

Parameters

right Right geometry

Returns

GeoSpatialValue Intersection of self and right

intersects(self, right)

Check if the geometries share any points.

Parameters

right Right geometry

Returns

BooleanValue Whether self intersects right

is_valid(self)

Check if the geometry is valid.

Returns

BooleanValue Whether self is valid

length(self)

Compute the length of a geospatial expression.

Returns

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

right Point geometry

Returns

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

GeoSpatialValue 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

start Start value end End value

Returns

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

right Right geometry

Returns

FloatingValue Maximum distance

n_points(self)

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

Returns

IntegerValue Number of points

n_rings(self)

Return the number of rings for polygons and multipolygons.

Outer rings are counted as well.

Returns

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

right Right geometry

Returns

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

right Right geometry

Returns

BooleanValue Overlaps indicator

perimeter(self)

Compute the perimeter of a geospatial expression.

Returns

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

n Nth point index

Returns

PointValue Nth point in self

set_srid(self, srid)

Set the spatial reference identifier for the ST_Geometry.

Parameters

srid SRID integer value

Returns

GeoSpatialValue self with SRID set to srid

simplify(self, tolerance, preserve_collapsed)

Simplify a given geometry.

Parameters

tolerance Tolerance preserve_collapsed Whether to preserve collapsed geometries

Returns

GeoSpatialValue Simplified geometry

srid(self)

Return the spatial reference identifier for the ST_Geometry.

Returns

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

PointValue Start point

touches(self, right)

Check if the geometries have at least one point in common, but do not intersect.

Parameters

right Right geometry

Returns

BooleanValue Whether self and right are touching

transform(self, srid)

Transform a geometry into a new SRID.

Parameters

srid Integer expression

Returns

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

right Right geometry

Returns

GeoSpatialValue Union of geometries

within(self, right)

Check if the first geometry is completely inside of the second.

Parameters

right Right geometry

Returns

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

FloatingValue X coordinate of self

x_max(self)

Return the X maxima of a geometry.

Returns

FloatingValue X maxima

x_min(self)

Return the X minima of a geometry.

Returns

FloatingValue X minima

y(self)

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

Input must be a point.

Returns

FloatingValue Y coordinate of self

y_max(self)

Return the Y maxima of a geometry.

Returns

FloatingValue Y maxima

y_min(self)

Return the Y minima of a geometry.

Returns

FloatingValue Y minima


Last update: February 3, 2022