Skip to content

Commit d553fa2

Browse files
authored
docs: update GeoSeries.difference() and bigframes.bigquery.st_difference() docs (#1526)
* docs: update GeoSeries.difference() and bigframes.bigquery.st_difference() docs * update variable names for readability
1 parent 9ff3fa8 commit d553fa2

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed

bigframes/bigquery/_operations/geo.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
def st_area(series: bigframes.series.Series) -> bigframes.series.Series:
2929
"""
3030
Returns the area in square meters covered by the polygons in the input
31-
GEOGRAPHY.
31+
`GEOGRAPHY`.
3232
3333
If geography_expression is a point or a line, returns zero. If
3434
geography_expression is a collection, returns the area of the polygons
3535
in the collection; if the collection doesn't contain polygons, returns zero.
3636
3737
38-
..note::
38+
.. note::
3939
BigQuery's Geography functions, like `st_area`, interpret the geometry
4040
data type as a point set on the Earth's surface. A point set is a set
4141
of points, lines, and polygons on the WGS84 reference spheroid, with
@@ -98,14 +98,14 @@ def st_difference(
9898
series: bigframes.series.Series, other: bigframes.series.Series
9999
) -> bigframes.series.Series:
100100
"""
101-
Returns a GEOGRAPHY that represents the point set difference of
101+
Returns a `GEOGRAPHY` that represents the point set difference of
102102
`geography_1` and `geography_2`. Therefore, the result consists of the part
103103
of `geography_1` that doesn't intersect with `geography_2`.
104104
105-
If `geometry_1` is completely contained in `geometry_2`, then ST_DIFFERENCE
106-
returns an empty GEOGRAPHY.
105+
If `geometry_1` is completely contained in `geometry_2`, then `ST_DIFFERENCE`
106+
returns an empty `GEOGRAPHY`.
107107
108-
..note::
108+
.. note::
109109
BigQuery's Geography functions, like `st_difference`, interpret the geometry
110110
data type as a point set on the Earth's surface. A point set is a set
111111
of points, lines, and polygons on the WGS84 reference spheroid, with
@@ -119,7 +119,7 @@ def st_difference(
119119
>>> from shapely.geometry import Polygon, LineString, Point
120120
>>> bpd.options.display.progress_bar = None
121121
122-
We can check two GeoSeries against each other, row by row.
122+
We can check two GeoSeries against each other, row by row:
123123
124124
>>> s1 = bigframes.geopandas.GeoSeries(
125125
... [
@@ -168,32 +168,32 @@ def st_difference(
168168
169169
We can also check difference of single shapely geometries:
170170
171-
>>> sbq1 = bigframes.geopandas.GeoSeries(
171+
>>> polygon_s1 = bigframes.geopandas.GeoSeries(
172172
... [
173173
... Polygon([(0, 0), (10, 0), (10, 10), (0, 0)])
174174
... ]
175175
... )
176-
>>> sbq2 = bigframes.geopandas.GeoSeries(
176+
>>> polygon_s2 = bigframes.geopandas.GeoSeries(
177177
... [
178178
... Polygon([(4, 2), (6, 2), (8, 6), (4, 2)])
179179
... ]
180180
... )
181181
182-
>>> sbq1
182+
>>> polygon_s1
183183
0 POLYGON ((0 0, 10 0, 10 10, 0 0))
184184
dtype: geometry
185185
186-
>>> sbq2
186+
>>> polygon_s2
187187
0 POLYGON ((4 2, 6 2, 8 6, 4 2))
188188
dtype: geometry
189189
190-
>>> bbq.st_difference(sbq1, sbq2)
190+
>>> bbq.st_difference(polygon_s1, polygon_s2)
191191
0 POLYGON ((0 0, 10 0, 10 10, 0 0), (8 6, 6 2, 4...
192192
dtype: geometry
193193
194194
Additionally, we can check difference of a GeoSeries against a single shapely geometry:
195195
196-
>>> bbq.st_difference(s1, sbq2)
196+
>>> bbq.st_difference(s1, polygon_s2)
197197
0 POLYGON ((0 0, 2 2, 0 2, 0 0))
198198
1 None
199199
2 None

third_party/bigframes_vendored/geopandas/geoseries.py

+18-23
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ def to_wkt(self) -> bigframes.series.Series:
242242

243243
def difference(self: GeoSeries, other: GeoSeries) -> GeoSeries: # type: ignore
244244
"""
245-
Returns a GeoSeries of the points in each aligned geometry that are not
246-
in other.
245+
Returns a GeoSeries of the points in each aligned geometry that are not
246+
in other.
247247
248-
The operation works on a 1-to-1 row-wise manner
248+
The operation works on a 1-to-1 row-wise manner.
249249
250250
**Examples:**
251251
@@ -254,7 +254,7 @@ def difference(self: GeoSeries, other: GeoSeries) -> GeoSeries: # type: ignore
254254
>>> from shapely.geometry import Polygon, LineString, Point
255255
>>> bpd.options.display.progress_bar = None
256256
257-
We can check two GeoSeries against each other, row by row.
257+
We can check two GeoSeries against each other, row by row:
258258
259259
>>> s1 = bigframes.geopandas.GeoSeries(
260260
... [
@@ -303,52 +303,47 @@ def difference(self: GeoSeries, other: GeoSeries) -> GeoSeries: # type: ignore
303303
304304
We can also check difference of single shapely geometries:
305305
306-
>>> sbq1 = bigframes.geopandas.GeoSeries(
306+
>>> polygon_s1 = bigframes.geopandas.GeoSeries(
307307
... [
308308
... Polygon([(0, 0), (10, 0), (10, 10), (0, 0)])
309309
... ]
310310
... )
311-
>>> sbq2 = bigframes.geopandas.GeoSeries(
311+
>>> polygon_s2 = bigframes.geopandas.GeoSeries(
312312
... [
313313
... Polygon([(4, 2), (6, 2), (8, 6), (4, 2)])
314314
... ]
315315
... )
316316
317-
>>> sbq1
317+
>>> polygon_s1
318318
0 POLYGON ((0 0, 10 0, 10 10, 0 0))
319319
dtype: geometry
320320
321-
>>> sbq2
321+
>>> polygon_s2
322322
0 POLYGON ((4 2, 6 2, 8 6, 4 2))
323323
dtype: geometry
324324
325-
>>> sbq1.difference(sbq2)
325+
>>> polygon_s1.difference(polygon_s2)
326326
0 POLYGON ((0 0, 10 0, 10 10, 0 0), (8 6, 6 2, 4...
327327
dtype: geometry
328328
329329
Additionally, we can check difference of a GeoSeries against a single shapely geometry:
330330
331-
>>> s1.difference(sbq2)
331+
>>> s1.difference(polygon_s2)
332332
0 POLYGON ((0 0, 2 2, 0 2, 0 0))
333333
1 None
334334
2 None
335335
3 None
336336
4 None
337337
dtype: geometry
338338
339-
Args:
340-
other (GeoSeries or geometric object):
341-
The GeoSeries (elementwise) or geometric object to find the
342-
difference to.
343-
344-
Returns:
345-
bigframes.geopandas.GeoSeries:
346-
A GeoSeries of the points in each aligned geometry that are not
347-
in other.
339+
Args:
340+
other (bigframes.geopandas.GeoSeries or geometric object):
341+
The GeoSeries (elementwise) or geometric object to find the
342+
difference to.
348343
349-
Raises:
350-
NotImplementedError:
351-
GeoSeries.difference is not supported. Use
352-
bigframes.bigquery.st_difference(series), instead.
344+
Returns:
345+
bigframes.geopandas.GeoSeries:
346+
A GeoSeries of the points in each aligned geometry that are not
347+
in other.
353348
"""
354349
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)

0 commit comments

Comments
 (0)