@@ -348,8 +348,10 @@ def hilbert_distance(self, total_bounds=None, level=16):
348348 total_bounds : 4-element array, optional
349349 The spatial extent in which the curve is constructed (used to
350350 rescale the geometry midpoints). By default, the total bounds
351- of the full dask GeoDataFrame will be computed. If known, you
352- can pass the total bounds to avoid this extra computation.
351+ of the full dask GeoDataFrame will be computed (from the spatial
352+ partitions, if available, otherwise computed from the full
353+ dataframe). If known, you can pass the total bounds to avoid this
354+ extra computation.
353355 level : int (1 - 16), default 16
354356 Determines the precision of the curve (points on the curve will
355357 have coordinates in the range [0, 2^level - 1]).
@@ -362,7 +364,10 @@ def hilbert_distance(self, total_bounds=None, level=16):
362364 """
363365 # Compute total bounds of all partitions rather than each partition
364366 if total_bounds is None :
365- total_bounds = self .total_bounds
367+ if self .spatial_partitions is not None :
368+ total_bounds = self .spatial_partitions .total_bounds
369+ else :
370+ total_bounds = self .total_bounds
366371
367372 # Calculate hilbert distances for each partition
368373 distances = self .map_partitions (
@@ -396,20 +401,25 @@ def morton_distance(self, total_bounds=None, level=16):
396401 total_bounds : 4-element array, optional
397402 The spatial extent in which the curve is constructed (used to
398403 rescale the geometry midpoints). By default, the total bounds
399- of the full dask GeoDataFrame will be computed. If known, you
400- can pass the total bounds to avoid this extra computation.
404+ of the full dask GeoDataFrame will be computed (from the spatial
405+ partitions, if available, otherwise computed from the full
406+ dataframe). If known, you can pass the total bounds to avoid this
407+ extra computation.
401408 level : int (1 - 16), default 16
402409 Determines the precision of the Morton curve.
403410
404411 Returns
405412 -------
406413 dask.Series
407414 Series containing distances along the Morton curve
408- """
409415
416+ """
410417 # Compute total bounds of all partitions rather than each partition
411418 if total_bounds is None :
412- total_bounds = self .total_bounds
419+ if self .spatial_partitions is not None :
420+ total_bounds = self .spatial_partitions .total_bounds
421+ else :
422+ total_bounds = self .total_bounds
413423
414424 # Calculate Morton distances for each partition
415425 distances = self .map_partitions (
0 commit comments