I have created a multipolygon grid covering the entire globe using h3 library. from the code below
from shapely import Polygon, multipolygons
from geopandas import GeoDataFrame as gdf
from h3 import h3
import folium
# Polyfill a Geo Json with hexagons
geoJson1 = {'type': 'Polygon', 'coordinates': [[[90,-180],[90,0],[-90,0],[-90,-180]]]}
geoJson2 = {'type': 'Polygon', 'coordinates': [[[90,0],[90,180],[-90,180],[-90,0]]]}
hexagons = list(h3.polyfill(geoJson1, 1)) + list(h3.polyfill(geoJson2, 1))
# Plot hexagons
polylines = []
for hex in hexagons:
polygons = h3.h3_set_to_multi_polygon([hex], geo_json=False)
outlines = [loop for polygon in polygons for loop in polygon]
polyline = [outline + [outline[0]] for outline in outlines][0]
polylines.append(polyline)
hex_list = [Polygon(h) for h in polylines]
grid_gdf = gdf(geometry=hex_list, crs="EPSG:4326")
# Concatenating all the separate dataframes into one big DataFrame
grid_gdf.to_file("h3_test.shp")
I am trying to upload "h3_test.shp" as a .shp asset in GEE, but I get this error :
Error: Projection exception. Ensure the projection is specified correctly and the coordinates are within its valid area. Detailed error: Unable to transform edge (33.965356, -166.528928 to 33.965380, -166.528957) from EPSG:4326 PLANAR to EPSG:4326.. (Error code: 3)
Some of the polygons are defined accross the antimeridian. e.g :
[(9.615942399155195, 179.77693144202632), (5.889921754313889, 179.21716082489448), (2.9040374505798128, -178.02519665249852), (3.8210244943304374, -174.31673738369324), (7.9727938308414075, -173.38014762578527), (11.05195584369349, -176.35806599111405), (10.46324037683843, -178.23815999124182), (9.615942399155195, 179.77693144202632)]
And I wonder if this could be the reason for the error...
I have no more clue, but any help or hint would be very appreciated. Thank you very much in advance !