Open mgramagl opened 4 years ago
Hmmm. Not sure what's going on here, but I can confirm I'm getting the same results.
I tried on h3-py
versions
3.6.4
3.6.3
3.6.1
3.4.3
and each had exactly the same results you're getting.
I'll try to take a deeper look to figure out what's going on.
Here's the geo, for reference:
Digging into the code I see that there is an undocumented
polyfill_geojson
function which works. Is that one correct?
Ah, interesting. Let me take a look!
hexagons = h3.polyfill(geoJson, 6, geo_json_conformant=True)
should work for your original case. (res=9
is going to give you a ton of hexagons.)
Also, note that the Manhattan example above returns hexagons, but they're the wrong ones unless you use geo_json_conformant=True
.
Most of the library uses the (lat, lng) ordering, but the GeoJSON spec uses (lng, lat). That'll continue to trip up folks until we can make it consistent or more clear.
This is a part of the API that I think is still confusing, but we're stuck with for the time being due to backward compatibility. This is one of the things I'd like to clean up when we move h3
and h3-py
to v4.0.
If you have any thoughts on how to make this more clear, or usability in general, I'd love to hear it! It'll definitely help as we move to v4.0.
I use h3 for spatial joins because it is so much faster than any other approach based on geometry/rtrees, so polyfill is fundamental. IMHO, I would just take an array of lat,lng as input, and leave the burden of flipping the values to the user, instead of a dictionary as it is now.
Out of curiosity, what are the spatial join tasks you're doing? I'm curious because I wonder if we can identify a "core" operation that we might try to optimize.
And how are you computing the spatial joins now?
It is a kind of a geo lookup table. For instance, mapping a lat,lon to state code. There the approach based on rtrees is in my experiment (I use spark) much slower than the one based on h3 polygons (i.e., I compute an h3 from the lat,lon and then perform a join operation with the ids I get from the polyfill). For now I trade complexity with precision (as the state borders are not perfectly matched by polygons) but it is fine for my use case.
Hi,
I experienced the following error with h3-py code, in which I try to fill the convex hull of Los Angeles with level 9 hexagons.
Unfortunately, this ends up with
[]
an empty array.Instead, If I try to do the same with NYC I get consistent results
Am I missing something?