wookay / H3.jl

H3.jl ⬡ provides a Julia version of H3, Hexagonal hierarchical geospatial indexing system. https://github.com/uber/h3
Other
25 stars 4 forks source link

Incorrect H3 keys being returned with geoToH3 #17

Closed gabegm closed 3 years ago

gabegm commented 3 years ago

Hi there, not sure if this is a bug or some wrong doing of mine, my apologies if it's the latter, although I have cross checked the results with H3 viz web apps and am not getting the same results.

Problem description

Environment information

Details

Status `~/code/H3Examples.jl/Project.toml`
  [88353bc9] ConfParser v0.1.2
  [a93c6f00] DataFrames v1.2.2
  [03d121ae] GooglePlaces v0.1.0 `https://github.com/gabegm/GooglePlaces.jl#main`
  [f62fece2] H3 v0.2.0
  [e6f89c97] LoggingExtras v0.4.7
  [e1d29d7a] Missings v1.0.2
  [626c502c] Parquet v0.8.3
julia> gd = [
           (11.474228, 48.144711), # west
           (11.666443, 48.138521) # east
       ]
2-element Vector{Tuple{Float64, Float64}}:
 (11.474228, 48.144711)
 (11.666443, 48.138521)

julia> [geoToH3(GeoCoord(deg2rad.(location)...), 4) for location in gd]
2-element Vector{UInt64}:
 0x08452c89ffffffff
 0x08452c89ffffffff

First Point Screenshot 2021-09-23 at 16-33-09 Google Maps

Second Point Screenshot 2021-09-23 at 16-33-34 Google Maps

H3 Visualiser 1st example Screenshot 2021-09-23 at 16-32-27 H3

H3 Visualiser 2nd example Screenshot 2021-09-23 at 16-44-17 H3 index visualizer Seth Miller Observable

wookay commented 3 years ago

could you provide the expected unique h3 indexes? I test it with https://github.com/uber/h3-py it also get the same 8452c89ffffffff.

import h3

resolution = 3
print("resolution3: ", h3.geo_to_h3(11.474228, 48.144711, resolution),
                       h3.geo_to_h3(11.666443, 48.138521, resolution))
resolution = 4
print("resolution4: ", h3.geo_to_h3(11.474228, 48.144711, resolution),
                       h3.geo_to_h3(11.666443, 48.138521, resolution))
resolution = 5
print("resolution5: ", h3.geo_to_h3(11.474228, 48.144711, resolution),
                       h3.geo_to_h3(11.666443, 48.138521, resolution))
resolution3:  8352c8fffffffff 8352ccfffffffff
resolution4:  8452c89ffffffff 8452c89ffffffff
resolution5:  8552c887fffffff 8552cc2ffffffff
gabegm commented 3 years ago

Thanks for the speedy reply!

Maybe I have this wrong, but shouldn't I be getting two unique H3 keys for both coordinates as per the two examples in the screenshots above?

Could this be an incorrect projection?

hs-ye commented 3 years ago

Hey guys just took a quick look, I think you have the co-ordinates in backwards

julia> gd = [
           (48.144711, 11.474228), # west (lat, lon)
           (48.138521, 11.666443) # east
       ]
2-element Vector{Tuple{Float64, Float64}}:
 (48.144711, 11.474228)
 (48.138521, 11.666443)

julia> [geoToH3(GeoCoord(deg2rad.(location)...), 4) for location in gd]
2-element Vector{UInt64}:
 0x0841f8d5ffffffff
 0x0841f8d7ffffffff

this worked for me!

gabegm commented 3 years ago

Many thanks @spcogg!!