Skip to content

False visualization of h3 polygons crossing the antimeridian #187

@relativityhd

Description

@relativityhd

Cells which cross the -180 / 180 antimeridian are inverted along the long axis in the visualization.

Image

Minimal reproducable example:

from xdggs.h3 import H3Info

level = 3
grid_info = H3Info(level=level)


lon = xr.DataArray(np.arange(-180, 180, 0.25), dims="lon")
lat = xr.DataArray(np.arange(50, 85, 0.25), dims="lat")
lon, lat = xr.broadcast(lon, lat)

h3_ds = xr.Dataset(
    coords={
        "cell_ids": (
            "cells",
            grid_info.geographic2cell_ids(lon.data.ravel(), lat.data.ravel()),
            grid_info.to_dict(),
        )
    }
).pipe(xdggs.decode)
h3_ds["lons"] = (["cells"], lon.data.ravel())
h3_ds.lons.dggs.explore()

Since the values plotted are the longitudes, this should result in a nice horizontal gradient.

However, this results in:

Image

By removing the antimeridian hexagons with replacing the lons line:

lon = xr.DataArray(np.arange(-180, 180, 0.25), dims="lon")

The result is as expected:

Image

I know that Geopandas has the same problem with folium.

Env-Info:

  • Python 3.12
  • XDGGS: 0.3.0
  • lonboard 0.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions