> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GeoDataFrame.hilbert_distance

> Calculate the distance along a Hilbert curve.

Calculate the distance along a Hilbert curve.

Distances are calculated from geometry-envelope midpoints and can be
used to spatially order a GeoSeries or GeoDataFrame by mapping its
two-dimensional geometries onto a one-dimensional curve.

## Signature

```python theme={"system"}
hilbert_distance(total_bounds=None, level=16)
```

## Parameters

<ParamField path="total_bounds" type="4-element array-like" default="None">
  The spatial extent in which the curve is constructed, used to
  rescale geometry midpoints. By default, the extent of all
  geometry-envelope midpoints is computed. Passing known bounds
  avoids that metadata computation.
</ParamField>

<ParamField path="level" type="int" default="16">
  Determines the precision of the curve. Documented levels are 1
  through 16, with grid coordinates in the range
  `[0, 2**level - 1]`.
</ParamField>

## Returns

<ResponseField name="return" type="pandas-on-Spark Series">
  Distributed Series named `"hilbert_distance"`. Spark stores
  the unsigned 32-bit Hilbert values as signed 64-bit integers.
</ResponseField>

<Note>
  The method performs one eager distributed validation and metadata
  aggregation. Geometry rows and the returned values remain distributed;
  no geometry data are collected on the driver.
</Note>

## Examples

```python theme={"system"}
>>> from shapely.geometry import Point
>>> from sedona.spark.geopandas import GeoSeries
>>> s = GeoSeries([Point(0, 0), Point(1, 1), Point(1, 0)])
>>> s.hilbert_distance(total_bounds=(0, 0, 1, 1), level=2).to_list()
[0, 10, 15]
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.