如何在 H3 中填充多重多边形?

Dak*_*hin 2 geojson h3

我有一组 GeoJSON 格式的多边形,例如:

{ 
  "type": "MultiPolygon",
  "coordinates": [
    [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
    [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
     [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
  ]
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用polyfill_geojsonH3 库中的方法来获取其中的六边形。但这个方法似乎只支持多边形而不支持多重多边形:

>>> h3.polyfill_geojson(geojson, 8)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "python3.7/site-packages/h3/api/_api_template.py", line 486, in polyfill_geojson
    mv = _cy.polyfill_geojson(geojson, res)
  File "geo.pyx", line 186, in h3._cy.geo.polyfill_geojson
ValueError: Only Polygon GeoJSON supported
Run Code Online (Sandbox Code Playgroud)

如何从 Multipolygon GeoJSON 中获取 H3 六边形?

use*_*060 5

简单......这将为您提供一个集合列表(您可以轻松加入)。

 [h3.polyfill(shapely.geometry.mapping(x)) for x in list(shapely.geometry.loads(geojson))]
Run Code Online (Sandbox Code Playgroud)