# 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.

### Examples

<div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesShowIframe('683480b9-2ab9-47c9-a206-d9d48d8d18c3','95c62105-cd24-4474-9f05-b8f426216f93','5eb3ef79-81f0-41b7-9f6e-45720f1209fb','../lite/tree/../notebooks/index.html?path=c9a80cb5_e48d_43ed_b700_7414ddc37bd0.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="5eb3ef79-81f0-41b7-9f6e-45720f1209fb" class="try_examples_outer_iframe  hidden"><div class="try_examples_button_container"><button class="try_examples_button" onclick="window.tryExamplesHideIframe('683480b9-2ab9-47c9-a206-d9d48d8d18c3','5eb3ef79-81f0-41b7-9f6e-45720f1209fb')">Go Back</button><button class="try_examples_button" onclick="window.openInNewTab('683480b9-2ab9-47c9-a206-d9d48d8d18c3','5eb3ef79-81f0-41b7-9f6e-45720f1209fb')">Open In Tab</button></div><div id="95c62105-cd24-4474-9f05-b8f426216f93" class="jupyterlite_sphinx_iframe_container"></div></div><script>document.addEventListener("DOMContentLoaded", function() {window.loadTryExamplesConfig("../try_examples.json");});</script>

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