Giter VIP home page Giter VIP logo

h3.jl's Introduction

H3.jl ⬡

Documentation Build Status

H3.jl provides Julia bindings to h3, a hexagonal, hierarchical geospatial indexing system. See the source code for the underlying C library at https://github.com/uber/h3.

using H3.API

base = latLngToCell(LatLng(deg2rad(0), deg2rad(0)), 5)
rings = gridDisk(base, 1)

x = Vector{Float64}()
y = Vector{Float64}()
for boundary in cellToBoundary.(rings), geo in boundary
    push!(x, geo.lng)
    push!(y, geo.lat)
end

using UnicodePlots
@info :plot scatterplot(x, y)

plot.png

h3.jl's People

Contributors

asinghvi17 avatar juliatagbot avatar rgivry avatar wookay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

h3.jl's Issues

geoToH3 produces incorrect cell ids

Minimal reproducible example:
Python H3 lib

a, b = h3.geo_to_h3(53.5495,9.9599, H3_RES), h3.geo_to_h3(53.5492,9.93109, H3_RES)

h3.h3_distance(a,b), a, b

produces:
(0, '851f1533fffffff', '851f1533fffffff')

This library produces:

a, b = geoToH3(GeoCoord(53.5495,9.9599), H3_RES), geoToH3(GeoCoord(53.5492,9.93109), H3_RES)

h3Distance(a,b), a, b

(10, 0x08596a833fffffff, 0x08596f4cffffffff)

These points are very close to one another...am I doing something wrong or is this just a really big hairy bug?

Compact doesn't always return the same number of valid H3 indexes

Compact always returns an array of the same length of the input h3Set, however some of the returned elements are not H3Indexes of the compacted set. Doing a list comprehension to get the valid ones yields inconsistent results.

Attached is a set of H3Indexes and a jupyter notebook demonstrating the above.
compact_issue.zip
And a screenshot for readability:
image.

My guess is that undef happens to luck onto valid H3Indexes so my suggested fix is to initialize the compactedSet with zeros (an H3Index that is guaranteed to be invalid - see here), and potentially incorporate the list comprehension to return only the valid H3Indexes before returning.

Happy to put up a pull request.

kRing returns invalid indexes

Thanks a lot for developing this package. While working with it I came across an issue that you can reproduce with the code below. It seems that kRing generates some invalid h3 indexes:

using H3.API
using Printf

idx = 0x85300537fffffff
idx = 0x8530158ffffffff
idx = 0x85301dc7fffffff

h3IsValid(idx)
geo = h3ToGeo(idx)
println(rad2deg(geo.lon))
println(rad2deg(geo.lat))

idxs = kRing(idx, 15);
println(length(idxs))

for i in idxs
    if !h3IsValid(i)
        print(@sprintf("wrong index 0x%08x \n", i))
        geo = h3ToGeo(i)
    end
end

Can't build package (v0.1.2, Julia 1.4.1)

I'm unable to build H3 on Julia 1.4.1 / macOS in a clean environment with nothing else. I didn't see any installation instructions in the readme, so I assume the package manager is the preferred installation method. Build error and versioninfo:

(justh3) pkg> add H3
   Updating registry at `~/.julia/registries/General`
   Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Resolving package versions...
   Updating `~/Desktop/justh3/Project.toml`
  [f62fece2] + H3 v0.1.2
   Updating `~/Desktop/justh3/Manifest.toml`
  [b99e7846] + BinaryProvider v0.5.9
  [fa961155] + CEnum v0.2.0
  [f62fece2] + H3 v0.1.2
  [8f399da3] + Libdl
  [56ddb016] + Logging
  [ea8e919c] + SHA

(justh3) pkg> build
   Building H3 → `~/.julia/packages/H3/F4Z32/deps/build.log`
┌ Error: Error building `H3`:
│ ERROR: LoadError: LibraryProduct(nothing, ["libh3"], :libh3, "Prefix(/Users/evan/.julia/packages/H3/F4Z32/deps/usr)") is not satisfied, cannot generate deps.jl!
│ Stacktrace:
│  [1] error(::String) at ./error.jl:33
│  [2] write_deps_file(::String, ::Array{LibraryProduct,1}; verbose::Bool, isolate::Bool) at /Users/evan/.julia/packages/BinaryProvider/GeAtj/src/Products.jl:419
│  [3] top-level scope at /Users/evan/.julia/packages/H3/F4Z32/deps/build.jl:48
│  [4] include(::String) at ./client.jl:439
│  [5] top-level scope at none:5
│ in expression starting at /Users/evan/.julia/packages/H3/F4Z32/deps/build.jl:48
└ @ Pkg.Operations /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Pkg/src/Operations.jl:892

julia> versioninfo()
Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Incorrect H3 keys being returned with geoToH3

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

  • Get h3 keys for two points at resolution 4
  • Expected result: 2 unique H3 keys are returned
  • Actual result: 2 duplicate H3 keys are returned

Environment information

  • Julia 1.6.2
  • macOS 11.5.2

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.