Closed jashanbhullar closed 11 months ago
The shapes aren't weird, they're just being rendered poorly. When H3 (and h3-js
) outputs shapes that cross the antimeridian, we keep all longitude values within the -180 - 180
range, so you may have some cells that have some western coordinates at longitude 179
and some eastern coordinates at -179
. Many maps will render this badly, but from a geographic shape perspective this is correct.
Either PostGIS or ogr2ogr
is taking the approach of cutting these cells into multipolygons, with one poly on one side of the antimeridian and one poly on the other. Normally I'd expect to see the dividing line rendered as well, but possibly your renderer expects this input and drops the dividing border. This is a perfectly good rendering solution, but I don't consider it a good generic solution because it gives you two shapes for some cells, instead of one.
Depending on your requirements, you can post-process the h3-js
output to render better, either by running it through a tool that can cut it up, or by normalizing the coordinates to extend past -180
and 180
. See this fixTransmeridian function for an example of the latter approach.
So I was creating a map using different indexes of h3. The idea is to get all the h3index and convert them into geojson which can be loaded on the map. I wrote a simple script for this.
The file it writes has weird shapes. I tried creating the shapes from PostGIS and it's perfect.
From h3-js lib From postgis geojson
For Postgis I used
and then exported the table using
ogr2ogr
I also noticed that some polygons in the postgis.json are MultiPolygons :thinking:
Attached are the files for reference, h3-js.polygon.json postgis.polygon.json
I want to understand why is this happening and how can I fix my script to get the same result I got from postgis!