# xarray.register_dataset_accessor

### xarray.register_dataset_accessor(name)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/extensions.py#L81-L124)

Register a custom property on xarray.Dataset objects.

* **Parameters:**
  **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Name under which the accessor should be registered. A warning is issued
  if this name conflicts with a preexisting attribute.

#### SEE ALSO
[`register_dataarray_accessor`](xarray.register_dataarray_accessor.html.md#xarray.register_dataarray_accessor)

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('6b7b6fc2-a624-41d7-87a7-ed4e86ff6b5c','4653c7d5-7788-44e9-8432-4d17ef818172','b98e5c1e-2c3a-4b7b-8082-7c1516e23be1','../lite/tree/../notebooks/index.html?path=8b7215f5_8484_4a23_b704_67f8f0210562.ipynb','None')">Try it in your browser!</button></div>

In your library code:

```pycon
>>> @xr.register_dataset_accessor("geo")
... class GeoAccessor:
...     def __init__(self, xarray_obj):
...         self._obj = xarray_obj
...
...     @property
...     def center(self):
...         # return the geographic center point of this dataset
...         lon = self._obj.latitude
...         lat = self._obj.longitude
...         return (float(lon.mean()), float(lat.mean()))
...
...     def plot(self):
...         # plot this array's data on a map, e.g., using Cartopy
...         pass
...
```

Back in an interactive IPython session:

```pycon
>>> ds = xr.Dataset(
...     {"longitude": np.linspace(0, 10), "latitude": np.linspace(0, 20)}
... )
>>> ds.geo.center
(10.0, 5.0)
>>> ds.geo.plot()  # plots data on a map
```

<div id="b98e5c1e-2c3a-4b7b-8082-7c1516e23be1" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('6b7b6fc2-a624-41d7-87a7-ed4e86ff6b5c','b98e5c1e-2c3a-4b7b-8082-7c1516e23be1')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('6b7b6fc2-a624-41d7-87a7-ed4e86ff6b5c','b98e5c1e-2c3a-4b7b-8082-7c1516e23be1')">Open In Tab</button></div><div id="4653c7d5-7788-44e9-8432-4d17ef818172" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>
