Functions¶
Array/Chunked Array functions¶
geoarrow.rust.compute ¶
affine_transform ¶
affine_transform(
input: ArrowArrayExportable | ArrowStreamExportable,
transform: AffineTransform,
) -> NativeArray | ChunkedNativeArray
Apply an affine transformation to geometries.
This is intended to be equivalent to shapely.affinity.affine_transform
for 2D
transforms.
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array other: an affine
Returns:
-
NativeArray | ChunkedNativeArray
–New GeoArrow array or chunked array with the same type as input and with
-
NativeArray | ChunkedNativeArray
–transformed coordinates.
area ¶
area(
input: ArrowArrayExportable | ArrowStreamExportable,
*,
method: AreaMethod | AreaMethodT = AreaMethod.Euclidean
) -> Array | ChunkedArray
Determine the area of an array of geometries
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array
Other Parameters:
-
method
(AreaMethod | AreaMethodT
) –The method to use for area calculation. One of "Ellipsoidal", "Euclidean", or "Spherical". Refer to the documentation on AreaMethod for more information.
Returns:
-
Array | ChunkedArray
–Array or chunked array with area values.
center ¶
center(
input: ArrowArrayExportable | ArrowStreamExportable,
) -> NativeArray | ChunkedNativeArray
Compute the center of geometries
This first computes the axis-aligned bounding rectangle, then takes the center of that box
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array
Returns:
-
NativeArray | ChunkedNativeArray
–Array or chunked array with center values.
centroid ¶
centroid(
input: ArrowArrayExportable | ArrowStreamExportable,
) -> NativeArray | ChunkedNativeArray
Calculation of the centroid.
The centroid is the arithmetic mean position of all points in the shape. Informally, it is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin.
The geometric centroid of a convex object always lies in the object. A non-convex object might have a centroid that is outside the object itself.
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array
Returns:
-
NativeArray | ChunkedNativeArray
–Array or chunked array with centroid values.
chaikin_smoothing ¶
chaikin_smoothing(
input: ArrowArrayExportable | ArrowStreamExportable, n_iterations: int
) -> NativeArray | ChunkedNativeArray
Smoothen LineString
, Polygon
, MultiLineString
and MultiPolygon
using
Chaikins algorithm.
Each iteration of the smoothing doubles the number of vertices of the geometry, so in some cases it may make sense to apply a simplification afterwards to remove insignificant coordinates.
This implementation preserves the start and end vertices of an open linestring and smoothes the corner between start and end of a closed linestring.
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array n_iterations: Number of iterations to use for smoothing.
Returns:
-
NativeArray | ChunkedNativeArray
–Smoothed geometry array or chunked geometry array.
convex_hull ¶
convex_hull(
input: ArrowArrayExportable | ArrowStreamExportable,
) -> NativeArray | ChunkedNativeArray
Returns the convex hull of a Polygon. The hull is always oriented counter-clockwise.
This implementation uses the QuickHull algorithm, based on Barber, C. Bradford; Dobkin, David P.; Huhdanpaa, Hannu (1 December 1996) Original paper here: www.cs.princeton.edu/~dpd/Papers/BarberDobkinHuhdanpaa.pdf
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array
Returns:
-
NativeArray | ChunkedNativeArray
–Array with convex hull polygons.
densify ¶
densify(
input: ArrowArrayExportable, max_distance: float
) -> NativeArray | ChunkedNativeArray
Return a new linear geometry containing both existing and new interpolated
coordinates with a maximum distance of max_distance
between them.
Note: max_distance
must be greater than 0.
Parameters:
-
input
(ArrowArrayExportable
) –input geometry array
-
max_distance
(float
) –maximum distance between coordinates
Returns:
-
NativeArray | ChunkedNativeArray
–Densified geometry array
envelope ¶
envelope(
input: ArrowArrayExportable | ArrowStreamExportable,
) -> NativeArray | ChunkedNativeArray
Computes the minimum axis-aligned bounding box that encloses an input geometry
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array
Returns:
-
NativeArray | ChunkedNativeArray
–Array with axis-aligned bounding boxes.
frechet_distance ¶
frechet_distance(
input: ArrowArrayExportable | ArrowStreamExportable,
other: BroadcastGeometry,
) -> Array | ChunkedArray
Determine the similarity between two arrays of LineStrings
using the [Frechet
distance].
The Fréchet distance is a measure of similarity: it is the greatest distance between any point in A and the closest point in B. The discrete distance is an approximation of this metric: only vertices are considered. The parameter ‘densify’ makes this approximation less coarse by splitting the line segments between vertices before computing the distance.
Fréchet distance sweep continuously along their respective curves and the direction of curves is significant. This makes it a better measure of similarity than Hausdorff distance for curve or surface matching.
This implementation is based on [Computing Discrete Frechet Distance] by T. Eiter and H. Mannila.
[Frechet distance]: en.wikipedia.org/wiki/Fr%C3%A9chet_distance [Computing Discrete Frechet Distance]: www.kr.tuwien.ac.at/staff/eiter/et-archive/cdtr9464.pdf
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array other: the geometry or
Returns:
-
Array | ChunkedArray
–Array or chunked array with float distance values.
geodesic_perimeter ¶
geodesic_perimeter(
input: ArrowArrayExportable | ArrowStreamExportable,
) -> Array | ChunkedArray
Determine the perimeter of a geometry on an ellipsoidal model of the earth.
This uses the geodesic measurement methods given by Karney (2013).
For a polygon this returns the sum of the perimeter of the exterior ring and
interior rings. To get the perimeter of just the exterior ring of a polygon, do
polygon.exterior().geodesic_length()
.
Units¶
- return value: meter
Returns:
-
Array | ChunkedArray
–Array with output values.
is_empty ¶
is_empty(
input: ArrowArrayExportable | ArrowStreamExportable,
) -> Array | ChunkedArray
Returns True if a geometry is an empty point, polygon, etc.
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array
Returns:
-
Array | ChunkedArray
–Result array.
length ¶
length(
input: ArrowArrayExportable | ArrowStreamExportable,
*,
method: LengthMethod | LengthMethodT = LengthMethod.Euclidean
) -> Array | ChunkedArray
Calculation of the length of a Line
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array
Other Parameters:
-
method
(LengthMethod | LengthMethodT
) –The method to use for length calculation. One of "Ellipsoidal", "Euclidean", "Haversine", or "Vincenty". Refer to the documentation on LengthMethod for more information. Defaults to LengthMethod.Euclidean.
Returns:
-
Array | ChunkedArray
–Array or chunked array with length values.
line_interpolate_point ¶
line_interpolate_point(
input: ArrowArrayExportable | ArrowStreamExportable,
fraction: (
float
| int
| ArrowArrayExportable
| ArrowStreamExportable
| NumpyArrayProtocolf64
),
) -> NativeArray | ChunkedNativeArray
Returns a point interpolated at given distance on a line.
This is intended to be equivalent to shapely.line_interpolate_point
when
normalized=True
.
If the given fraction is
- less than zero (including negative infinity): returns the starting point
- greater than one (including infinity): returns the ending point
- If either the fraction is NaN, or any coordinates of the line are not
finite, returns
Point EMPTY
.
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array
-
fraction
(float | int | ArrowArrayExportable | ArrowStreamExportable | NumpyArrayProtocolf64
) –the fractional distance along the line. A variety of inputs are accepted:
- A Python
float
orint
- A numpy
ndarray
withfloat64
data type. - An Arrow array or chunked array with
float64
data type.
- A Python
Returns:
-
NativeArray | ChunkedNativeArray
–PointArray or ChunkedPointArray with result values
line_locate_point ¶
line_locate_point(
input: ArrowArrayExportable | ArrowStreamExportable,
point: GeoInterfaceProtocol | ArrowArrayExportable | ArrowStreamExportable,
) -> Array | ChunkedArray
Returns a fraction of the line's total length representing the location of the closest point on the line to the given point.
This is intended to be equivalent to shapely.line_locate_point
when
normalized=True
.
If the line has zero length the fraction returned is zero.
If either the point's coordinates or any coordinates of the line
are not finite, returns NaN
.
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array
-
point
(GeoInterfaceProtocol | ArrowArrayExportable | ArrowStreamExportable
) –the fractional distance along the line. A variety of inputs are accepted:
- A scalar
Geometry
- A
NativeArray
- A
ChunkedNativeArray
- Any Python class that implements the Geo Interface, such as a
shapely
Point - Any GeoArrow array or chunked array of
Point
type
- A scalar
Returns:
-
Array | ChunkedArray
–Array or chunked array with float fraction values.
polylabel ¶
polylabel(
input: ArrowArrayExportable | ArrowStreamExportable, tolerance: float
) -> NativeArray | ChunkedNativeArray
Calculate a Polygon's ideal label position by calculating its pole of inaccessibility.
The pole of inaccessibility is the most distant internal point from the polygon outline (not to be confused with centroid), and is useful for optimal placement of a text label on a polygon.
The calculation uses an iterative grid-based algorithm, ported from the original JavaScript implementation.
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array
-
tolerance
(float
) –precision of algorithm. Refer to the original JavaScript documentation for more information
Returns:
-
NativeArray | ChunkedNativeArray
–PointArray or ChunkedPointArray with result values
rotate ¶
rotate(
geom: ArrowArrayExportable | ArrowStreamExportable,
angle: float,
*,
origin: RotateOrigin | RotateOriginT | tuple[float, float]
) -> NativeArray | ChunkedNativeArray
scale ¶
scale(
geom: ArrowArrayExportable | ArrowStreamExportable,
xfact: float,
yfact: float,
) -> NativeArray | ChunkedNativeArray
Returns a scaled geometry, scaled by factors along each dimension.
Parameters:
-
geom
(ArrowArrayExportable | ArrowStreamExportable
) –description
-
xfact
(float
) –description
-
yfact
(float
) –description
Returns:
-
NativeArray | ChunkedNativeArray
–description
signed_area ¶
signed_area(
input: ArrowArrayExportable | ArrowStreamExportable,
*,
method: AreaMethod | AreaMethodT = AreaMethod.Euclidean
) -> Array | ChunkedArray
Signed area of a geometry array
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array or chunked geometry array
Other Parameters:
-
method
(AreaMethod | AreaMethodT
) –The method to use for area calculation. One of "Ellipsoidal", "Euclidean", or "Spherical". Refer to the documentation on AreaMethod for more information.
Returns:
-
Array | ChunkedArray
–Array or chunked array with area values.
simplify ¶
simplify(
input: ArrowArrayExportable | ArrowStreamExportable,
epsilon: float,
*,
method: SimplifyMethod | SimplifyMethodT = SimplifyMethod.RDP
) -> NativeArray | ChunkedNativeArray
Simplifies a geometry.
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array
-
epsilon
(float
) –tolerance for simplification. An epsilon less than or equal to zero will return an unaltered version of the geometry.
Other Parameters:
-
method
(SimplifyMethod | SimplifyMethodT
) –The method to use for simplification calculation. One of
"rdp"
,"vw"
, or"vw_preserve"
. Refer to the documentation on SimplifyMethod for more information. Defaults to SimplifyMethod.RDP.
Returns:
-
NativeArray | ChunkedNativeArray
–Simplified geometry array.
skew ¶
skew(
geom: ArrowArrayExportable | ArrowStreamExportable, xs: float, ys: float
) -> NativeArray | ChunkedNativeArray
Skew a geometry from it's bounding box center, using different values for xs
and
ys
to distort the geometry's aspect
ratio.
Parameters:
-
geom
(ArrowArrayExportable | ArrowStreamExportable
) –description
-
xs
(float
) –description
-
ys
(float
) –description
Returns:
-
NativeArray | ChunkedNativeArray
–description
total_bounds ¶
total_bounds(
input: ArrowArrayExportable | ArrowStreamExportable,
) -> Tuple[float, float, float, float]
Computes the total bounds (extent) of the geometry.
Parameters:
-
input
(ArrowArrayExportable | ArrowStreamExportable
) –input geometry array
Returns:
translate ¶
translate(
geom: ArrowArrayExportable | ArrowStreamExportable, xoff: float, yoff: float
) -> NativeArray | ChunkedNativeArray
Returns a scaled geometry, scaled by factors along each dimension.
Parameters:
-
geom
(ArrowArrayExportable | ArrowStreamExportable
) –description
-
xoff
(float
) –description
-
yoff
(float
) –description
Returns:
-
NativeArray | ChunkedNativeArray
–description
Table functions¶
geoarrow.rust.compute ¶
explode ¶
explode(input: ArrowStreamExportable) -> Table
Explode a table.
This is intended to be equivalent to the explode
function
in GeoPandas.
Parameters:
-
input
(ArrowStreamExportable
) –input table
Returns:
-
Table
–A new table with multi-part geometries exploded to separate rows.