Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions xdggs/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def cell_boundaries(self, cell_ids, backend="shapely"):
def zoom_to(self, cell_ids, level: int):
raise NotImplementedError()

def neighbours(self, cell_ids, ring=1):
raise NotImplementedError()


def translate_parameters(mapping, translations):
def translate(name, value):
Expand Down
9 changes: 7 additions & 2 deletions xdggs/h3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import xarray as xr

try:
from h3ronpy import change_resolution
from h3ronpy import change_resolution, grid_disk
from h3ronpy.vector import (
cells_to_coordinates,
cells_to_wkb_polygons,
coordinates_to_cells,
)
except ImportError:
from h3ronpy.arrow import change_resolution
from h3ronpy.arrow import change_resolution, grid_disk
from h3ronpy.arrow.vector import (
cells_to_coordinates,
cells_to_wkb_polygons,
Expand Down Expand Up @@ -205,6 +205,11 @@ def zoom_to(self, cell_ids, level):

return np.asarray(change_resolution(cell_ids, level))

def neighbours(self, cell_ids, ring=1):
neighbours = grid_disk(cell_ids, k=ring, flatten=False)

return neighbours


@register_dggs("h3")
class H3Index(DGGSIndex):
Expand Down
5 changes: 5 additions & 0 deletions xdggs/healpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ def zoom_to(self, cell_ids, level):

return zoom_to(cell_ids, self.level, level)

def neighbours(self, cell_ids, ring=1):
from healpix_geo.nested import kth_neighbourhood

return kth_neighbourhood(cell_ids, depth=self.level, ring=ring)


def construct_chunk_ranges(chunks, until):
start = 0
Expand Down