bigframes.bigquery.st_centroid#
- bigframes.bigquery.st_centroid(series: Series | GeoSeries) Series[source]#
Computes the geometric centroid of a GEOGRAPHY type.
For POINT and MULTIPOINT types, this is the arithmetic mean of the input coordinates. For LINESTRING and POLYGON types, this is the center of mass. For GEOMETRYCOLLECTION types, this is the center of mass of the collection’s elements.
Note
BigQuery’s Geography functions, like st_centroid, interpret the geometry data type as a point set on the Earth’s surface. A point set is a set of points, lines, and polygons on the WGS84 reference spheroid, with geodesic edges. See: https://cloud.google.com/bigquery/docs/geospatial-data
Examples:
>>> import bigframes.geopandas >>> import bigframes.pandas as bpd >>> import bigframes.bigquery as bbq >>> from shapely.geometry import Polygon, LineString, Point
>>> series = bigframes.geopandas.GeoSeries( ... [ ... Polygon([(0.0, 0.0), (0.1, 0.1), (0.0, 0.1)]), ... LineString([(0, 0), (1, 1), (0, 1)]), ... Point(0, 1), ... ] ... ) >>> series 0 POLYGON ((0 0, 0.1 0.1, 0 0.1, 0 0)) 1 LINESTRING (0 0, 1 1, 0 1) 2 POINT (0 1) dtype: geometry
>>> bbq.st_centroid(series) 0 POINT (0.03333 0.06667) 1 POINT (0.49998 0.70712) 2 POINT (0 1) dtype: geometry
- Parameters:
series (bigframes.pandas.Series | bigframes.geopandas.GeoSeries) – A series containing geography objects.
- Returns:
A series of geography objects representing the centroids.
- Return type: