Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
How to find point (lat, lng) inside a polygon with h3-js?

I have a polygon created with polyfill, is it possible to know if the point = [lat, lng] is in that polygon (using only h3-js)?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yes, this is possible, though there's simplification involved - polyfill returns cells whose centers fall within the polygon, so you'll have cases at the edges of the polygon where specific points near the edge will be incorrectly included or excluded from the polygon. The tradeoff is that the inclusion check should be much faster than a traditional point-in-poly algorithm, and the code is simpler:

// Create a set of H3 indexes representing the polygon. Using a finer
// value for H3_RES will give you better fidelity to the original 
// polygon, at the cost of more memory usage 
const polygonSet = new Set(h3.polyfill(myPolygon, H3_RES));

// Check whether a given point is in the polygon
function isPointInPoly(point) {
  const h3Index = h3.geoToH3(point.lat, point.lng, H3_RES);
  return polygonSet.has(h3Index);
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!