File tree Expand file tree Collapse file tree 5 files changed +61
-6
lines changed
Expand file tree Collapse file tree 5 files changed +61
-6
lines changed Original file line number Diff line number Diff line change 2929)
3030from bigframes .bigquery ._operations .geo import (
3131 st_area ,
32+ st_buffer ,
33+ st_centroid ,
34+ st_convex_hull ,
3235 st_difference ,
3336 st_distance ,
3437 st_intersection ,
5962 "array_to_string" ,
6063 # geo ops
6164 "st_area" ,
65+ "st_buffer" ,
66+ "st_centroid" ,
67+ "st_convex_hull" ,
6268 "st_difference" ,
6369 "st_distance" ,
6470 "st_intersection" ,
Original file line number Diff line number Diff line change @@ -1038,6 +1038,21 @@ def geo_st_boundary_op_impl(x: ibis_types.Value):
10381038 return st_boundary (x )
10391039
10401040
1041+ @scalar_op_compiler .register_unary_op (ops .GeoStBufferOp , pass_op = True )
1042+ def geo_st_buffer_op_impl (x : ibis_types .Value , op : ops .GeoStBufferOp ):
1043+ return typing .cast (ibis_types .GeoSpatialValue , x ).buffer (op .distance )
1044+
1045+
1046+ @scalar_op_compiler .register_unary_op (ops .geo_st_centroid_op , pass_op = False )
1047+ def geo_st_centroid_op_impl (x : ibis_types .Value ):
1048+ return typing .cast (ibis_types .GeoSpatialValue , x ).centroid ()
1049+
1050+
1051+ @scalar_op_compiler .register_unary_op (ops .geo_st_convexhull_op , pass_op = False )
1052+ def geo_st_convexhull_op_impl (x : ibis_types .Value ):
1053+ return typing .cast (ibis_types .GeoSpatialValue , x ).convex_hull ()
1054+
1055+
10411056@scalar_op_compiler .register_binary_op (ops .geo_st_difference_op , pass_op = False )
10421057def geo_st_difference_op_impl (x : ibis_types .Value , y : ibis_types .Value ):
10431058 return typing .cast (ibis_types .GeoSpatialValue , x ).difference (
Original file line number Diff line number Diff line change @@ -92,6 +92,15 @@ def to_wkt(self: GeoSeries) -> bigframes.series.Series:
9292 series .name = None
9393 return series
9494
95+ def buffer (self : GeoSeries , distance : float ) -> bigframes .series .Series : # type: ignore
96+ return self ._apply_unary_op (ops .GeoStBufferOp (distance = distance ))
97+
98+ def centroid (self : GeoSeries ) -> bigframes .series .Series : # type: ignore
99+ return self ._apply_unary_op (ops .geo_st_centroid_op )
100+
101+ def convex_hull (self : GeoSeries ) -> bigframes .series .Series : # type: ignore
102+ return self ._apply_unary_op (ops .geo_st_convexhull_op )
103+
95104 def difference (self : GeoSeries , other : GeoSeries ) -> bigframes .series .Series : # type: ignore
96105 return self ._apply_binary_op (other , ops .geo_st_difference_op )
97106
Original file line number Diff line number Diff line change 4242)
4343geo_st_boundary_op = GeoStBoundaryOp ()
4444
45+ GeoStCentroidOp = base_ops .create_unary_op (
46+ name = "geo_st_centroid" ,
47+ type_signature = op_typing .FixedOutputType (
48+ dtypes .is_geo_like , dtypes .GEO_DTYPE , description = "geo-like"
49+ ),
50+ )
51+ geo_st_centroid_op = GeoStCentroidOp ()
52+
53+ GeoStConvexhullOp = base_ops .create_unary_op (
54+ name = "geo_st_convexhull" ,
55+ type_signature = op_typing .FixedOutputType (
56+ dtypes .is_geo_like , dtypes .GEO_DTYPE , description = "geo-like"
57+ ),
58+ )
59+ geo_st_convexhull_op = GeoStConvexhullOp ()
60+
4561GeoStDifferenceOp = base_ops .create_binary_op (
4662 name = "geo_st_difference" , type_signature = op_typing .BinaryGeo ()
4763)
90106geo_st_intersection_op = GeoStIntersectionOp ()
91107
92108
109+ @dataclasses .dataclass (frozen = True )
110+ class GeoStBufferOp (base_ops .UnaryOp ):
111+ name = "st_buffer"
112+ distance : float
113+
114+ def output_type (self , * input_types : dtypes .ExpressionType ) -> dtypes .ExpressionType :
115+ return dtypes .GEO_DTYPE
116+
117+
93118@dataclasses .dataclass (frozen = True )
94119class GeoStDistanceOp (base_ops .BinaryOp ):
95120 name = "st_distance"
Original file line number Diff line number Diff line change @@ -79,9 +79,9 @@ functions should be exposed in the `bigframes.bigquery` module.
7979- [ ] GeoSeries.symmetric_difference
8080- [ ] GeoSeries.union
8181- [x] GeoSeries.boundary
82- - [ ] GeoSeries.buffer
83- - [ ] GeoSeries.centroid
84- - [ ] GeoSeries.concave_hull
82+ - [ WIP ] GeoSeries.buffer
83+ - [ WIP ] GeoSeries.centroid
84+ - [ WIP ] GeoSeries.concave_hull
8585- [ ] GeoSeries.convex_hull
8686- [ ] GeoSeries.envelope
8787- [ ] GeoSeries.extract_unique_points
@@ -174,12 +174,12 @@ Formatters: Functions that export geographies to an external format such as WKT.
174174Transformations: Functions that generate a new geography based on input.
175175
176176- [x] ST_BOUNDARY
177- - [ ] ST_BUFFER
177+ - [ WIP ] ST_BUFFER
178178- [ ] ST_BUFFERWITHTOLERANCE
179- - [ ] ST_CENTROID
179+ - [ WIP ] ST_CENTROID
180180- [ ] ST_CENTROID_AGG (Aggregate)
181181- [ ] ST_CLOSESTPOINT
182- - [ ] ST_CONVEXHULL
182+ - [ WIP ] ST_CONVEXHULL
183183- [x] ST_DIFFERENCE
184184- [ ] ST_EXTERIORRING
185185- [ ] ST_INTERIORRINGS
You can’t perform that action at this time.
0 commit comments