@@ -103,6 +103,187 @@ def st_area(
103
103
return series
104
104
105
105
106
+ def st_buffer (
107
+ series : Union [bigframes .series .Series , bigframes .geopandas .GeoSeries ],
108
+ buffer_radius : float ,
109
+ num_seg_quarter_circle : float = 8.0 ,
110
+ use_spheroid : bool = False ,
111
+ ) -> bigframes .series .Series :
112
+ """
113
+ Computes a `GEOGRAPHY` that represents all points whose distance from the
114
+ input `GEOGRAPHY` is less than or equal to `distance` meters.
115
+
116
+ .. note::
117
+ BigQuery's Geography functions, like `st_buffer`, interpret the geometry
118
+ data type as a point set on the Earth's surface. A point set is a set
119
+ of points, lines, and polygons on the WGS84 reference spheroid, with
120
+ geodesic edges. See: https://cloud.google.com/bigquery/docs/geospatial-data
121
+
122
+ **Examples:**
123
+
124
+ >>> import bigframes.geopandas
125
+ >>> import bigframes.pandas as bpd
126
+ >>> import bigframes.bigquery as bbq
127
+ >>> from shapely.geometry import Point
128
+ >>> bpd.options.display.progress_bar = None
129
+
130
+ >>> series = bigframes.geopandas.GeoSeries(
131
+ ... [
132
+ ... Point(0, 0),
133
+ ... Point(1, 1),
134
+ ... ]
135
+ ... )
136
+ >>> series
137
+ 0 POINT (0 0)
138
+ 1 POINT (1 1)
139
+ dtype: geometry
140
+
141
+ >>> buffer = bbq.st_buffer(series, 100)
142
+ >>> bbq.st_area(buffer) > 0
143
+ 0 True
144
+ 1 True
145
+ dtype: boolean
146
+
147
+ Args:
148
+ series (bigframes.pandas.Series | bigframes.geopandas.GeoSeries):
149
+ A series containing geography objects.
150
+ buffer_radius (float):
151
+ The distance in meters.
152
+ num_seg_quarter_circle (float, optional):
153
+ Specifies the number of segments that are used to approximate a
154
+ quarter circle. The default value is 8.0.
155
+ use_spheroid (bool, optional):
156
+ Determines how this function measures distance. If use_spheroid is
157
+ FALSE, the function measures distance on the surface of a perfect
158
+ sphere. The use_spheroid parameter currently only supports the
159
+ value FALSE. The default value of use_spheroid is FALSE.
160
+
161
+ Returns:
162
+ bigframes.pandas.Series:
163
+ A series of geography objects representing the buffered geometries.
164
+ """
165
+ op = ops .GeoStBufferOp (
166
+ buffer_radius = buffer_radius ,
167
+ num_seg_quarter_circle = num_seg_quarter_circle ,
168
+ use_spheroid = use_spheroid ,
169
+ )
170
+ series = series ._apply_unary_op (op )
171
+ series .name = None
172
+ return series
173
+
174
+
175
+ def st_centroid (
176
+ series : Union [bigframes .series .Series , bigframes .geopandas .GeoSeries ],
177
+ ) -> bigframes .series .Series :
178
+ """
179
+ Computes the geometric centroid of a `GEOGRAPHY` type.
180
+
181
+ For `POINT` and `MULTIPOINT` types, this is the arithmetic mean of the
182
+ input coordinates. For `LINESTRING` and `POLYGON` types, this is the
183
+ center of mass. For `GEOMETRYCOLLECTION` types, this is the center of
184
+ mass of the collection's elements.
185
+
186
+ .. note::
187
+ BigQuery's Geography functions, like `st_centroid`, interpret the geometry
188
+ data type as a point set on the Earth's surface. A point set is a set
189
+ of points, lines, and polygons on the WGS84 reference spheroid, with
190
+ geodesic edges. See: https://cloud.google.com/bigquery/docs/geospatial-data
191
+
192
+ **Examples:**
193
+
194
+ >>> import bigframes.geopandas
195
+ >>> import bigframes.pandas as bpd
196
+ >>> import bigframes.bigquery as bbq
197
+ >>> from shapely.geometry import Polygon, LineString, Point
198
+ >>> bpd.options.display.progress_bar = None
199
+
200
+ >>> series = bigframes.geopandas.GeoSeries(
201
+ ... [
202
+ ... Polygon([(0.0, 0.0), (0.1, 0.1), (0.0, 0.1)]),
203
+ ... LineString([(0, 0), (1, 1), (0, 1)]),
204
+ ... Point(0, 1),
205
+ ... ]
206
+ ... )
207
+ >>> series
208
+ 0 POLYGON ((0 0, 0.1 0.1, 0 0.1, 0 0))
209
+ 1 LINESTRING (0 0, 1 1, 0 1)
210
+ 2 POINT (0 1)
211
+ dtype: geometry
212
+
213
+ >>> bbq.st_centroid(series)
214
+ 0 POINT (0.03333 0.06667)
215
+ 1 POINT (0.49998 0.70712)
216
+ 2 POINT (0 1)
217
+ dtype: geometry
218
+
219
+ Args:
220
+ series (bigframes.pandas.Series | bigframes.geopandas.GeoSeries):
221
+ A series containing geography objects.
222
+
223
+ Returns:
224
+ bigframes.pandas.Series:
225
+ A series of geography objects representing the centroids.
226
+ """
227
+ series = series ._apply_unary_op (ops .geo_st_centroid_op )
228
+ series .name = None
229
+ return series
230
+
231
+
232
+ def st_convexhull (
233
+ series : Union [bigframes .series .Series , bigframes .geopandas .GeoSeries ],
234
+ ) -> bigframes .series .Series :
235
+ """
236
+ Computes the convex hull of a `GEOGRAPHY` type.
237
+
238
+ The convex hull is the smallest convex set that contains all of the
239
+ points in the input `GEOGRAPHY`.
240
+
241
+ .. note::
242
+ BigQuery's Geography functions, like `st_convexhull`, interpret the geometry
243
+ data type as a point set on the Earth's surface. A point set is a set
244
+ of points, lines, and polygons on the WGS84 reference spheroid, with
245
+ geodesic edges. See: https://cloud.google.com/bigquery/docs/geospatial-data
246
+
247
+ **Examples:**
248
+
249
+ >>> import bigframes.geopandas
250
+ >>> import bigframes.pandas as bpd
251
+ >>> import bigframes.bigquery as bbq
252
+ >>> from shapely.geometry import Polygon, LineString, Point
253
+ >>> bpd.options.display.progress_bar = None
254
+
255
+ >>> series = bigframes.geopandas.GeoSeries(
256
+ ... [
257
+ ... Polygon([(0.0, 0.0), (0.1, 0.1), (0.0, 0.1)]),
258
+ ... LineString([(0, 0), (1, 1), (0, 1)]),
259
+ ... Point(0, 1),
260
+ ... ]
261
+ ... )
262
+ >>> series
263
+ 0 POLYGON ((0 0, 0.1 0.1, 0 0.1, 0 0))
264
+ 1 LINESTRING (0 0, 1 1, 0 1)
265
+ 2 POINT (0 1)
266
+ dtype: geometry
267
+
268
+ >>> bbq.st_convexhull(series)
269
+ 0 POLYGON ((0 0, 0.1 0.1, 0 0.1, 0 0))
270
+ 1 POLYGON ((0 0, 1 1, 0 1, 0 0))
271
+ 2 POINT (0 1)
272
+ dtype: geometry
273
+
274
+ Args:
275
+ series (bigframes.pandas.Series | bigframes.geopandas.GeoSeries):
276
+ A series containing geography objects.
277
+
278
+ Returns:
279
+ bigframes.pandas.Series:
280
+ A series of geography objects representing the convex hulls.
281
+ """
282
+ series = series ._apply_unary_op (ops .geo_st_convexhull_op )
283
+ series .name = None
284
+ return series
285
+
286
+
106
287
def st_difference (
107
288
series : Union [bigframes .series .Series , bigframes .geopandas .GeoSeries ],
108
289
other : Union [
0 commit comments