Open willbowditch opened 1 year ago
The boundaries returned from H3 are not AntiMeridian safe and introduce the distortion we observe here.
df = spark.sql("SELECT st_astext(h3_boundaryaswkb(h3_longlatash3(-180,0,4))) as geometry")
df.display()
# POLYGON ((179.851079918 0.376375409, -179.955309354 0.347497759, -179.860401436 0.149076599, -179.959431042 -0.019774498, 179.847305581 0.009690979, 179.752724995 0.207421233, 179.851079918 0.376375409))
If you wrap the cell in carto.ST_AntimeridianSafeGeom it will return a Multipolygon split at the antimeridian
df = spark.sql("SELECT carto.st_astext(carto.ST_AntimeridianSafeGeom(carto.st_geomfromwkb(st_asbinary(h3_boundaryaswkb(h3_longlatash3(-180,0,4)))))) as geometry")
df.display()
# MULTIPOLYGON (((-180 -0.01359, -180 0.35417, -179.95531 0.3475, -179.8604 0.14908, -179.95943 -0.01977, -180 -0.01359)), ((180 0.35417, 180 -0.01359, 179.84731 0.00969, 179.75272 0.20742, 179.85108 0.37638, 180 0.35417)))
grid_tessellateexplode
and grid_tessellate
use the unsafe geometries when computing the intersection and hence generate corrupted output geometries.
@edurdevic, there is a straightforward implementation of the ST_antimeridianSafeGeom
from Geomesa using JTS and spatial4j. How far do you require feature parity between JTS and ESRI geometry API? Would you be open to supporting this for JTS only? Happy to make a PR for this.
@thomas-maschler JTS only support for ST_antimeridianSafeGeom is perfectly fine, we are planning to standardise around a single engine going forward (JTS). I will be updating our external contribution process today, going forward it will be possible to accept external PRs. I will provide a link to the README here once it is live.
Excellent! I was wondering about the geometry API. Going with JTS should make things much easier and provides ways to integrate with other OS libraries.
st_antimeridiansafe
is not pole save and it would still require some custom logic, but it should simplify the PR by a lot.
Describe the bug
If a geometry crosses the antimeridian the geometries created by
grid_tessalateexplode
can be larger than the h3 cell which should contain them.To Reproduce
The area of non
is_core
is larger thanis_core
cells:Expected behavior
The geometries should be contained within the H3 cell
Screenshots
The input geometry looks like this:
The output of the geometries which are larger than expected look like this:
Additional context
An example real-world polygon where this is a problem are geo-boundaries for Fiji, see:
https://media.githubusercontent.com/media/wmgeolab/geoBoundaries/a6ef6576d347e3885a3ec4891b95b26e76668cbe/releaseData/gbOpen/FJI/ADM0/geoBoundaries-FJI-ADM0-all.zip