Questions tagged [point-in-polygon]

Algorithm for determining whether a point is inside a polygon. Normally calculated by counting the number of polygon line segments that a ray from the point intersects.

275 questions
3
votes
2 answers

Javascript: point-in-polygon performance improvement

I have an array of objects. Each object represents a point has an ID and an array with x y coordinates. , e.g.: let points = [{id: 1, coords: [1,2]}, {id: 2, coords: [2,3]}] I also have an array of arrays containing x y coordinates. This array…
3
votes
1 answer

Calculate if point coordinates is inside polygon with concave and convex angles ? Javascript

sorry for my english but i'm italian... i would like to create a code that calculate if point (with two coordinates) is inside polygon with concave and convex angles. I tried few codes because is too difficult.. var polygon = [ …
Borja
  • 3,359
  • 7
  • 33
  • 66
3
votes
1 answer

impoly only approximately correct on log-scale axes

When determining points within polygons using MATLAB's inpolygon function, I find that the results are exactly correct for polygons drawn on linear axes but only approximately correct for polygons drawn on log-scale axes. Although my suspicions lean…
user001
  • 1,850
  • 4
  • 27
  • 42
3
votes
2 answers

Retrieve set of rectangles containing a specified point

I can't figure out how to implement this in a performing way, so I decided to ask you guys. I have a list of rectangles - actually atm only squares, but I might have to migrate to rectangles later, so let's stick to them and keep it a bit more…
Daniel Baulig
  • 10,739
  • 6
  • 44
  • 43
3
votes
1 answer

Determine in which polygons a point is

I have tremendous flows of point data (in 2D) (thousands every second). On this map I have several fixed polygons (dozens to a few hundreds of them). I would like to determine in real time (the order of a few milliseconds on a rather powerful…
Robin
  • 605
  • 2
  • 8
  • 25
3
votes
1 answer

Algorithm for how to Split Large Area into Convex Polygons

I'm implementing the A* pathfinding algorithm into a grid based engine, but I'm wanting to create nodes in polygonal areas rather than just using the grid points. There will be obstacles in the area, that shouldn't be moved through. I'm wondering…
3
votes
1 answer

Algorithm for fast point lookup and line of sight traversal

I'm putting together a small library that consumes Geographic Information System (GIS) data and allows for fast point in feature, point near feature, and line of sight queries. Much of this data will consist of big areal features with enormous…
mousebird
  • 1,029
  • 9
  • 18
3
votes
1 answer

Select one feature of multiple overlapping features (here polygons) on a Leaflet map

I have a map with multiple polygons rendered on it which can overlap eachother. I use leafletPip.pointInLayer(point, layer) from https://github.com/mapbox/leaflet-pip for determining which polygons do overlap. This happens in the processClick…
Flugmango
  • 113
  • 2
  • 11
3
votes
2 answers

Winding number algorithm and point on boundary/edge of convex

I need algorithm which can tell, if Point lies inside/outside or on boundary (edge) of convex hull (C/C++). Convex hull is described as array of Points X,Y, integer, connection are from i to i+1. Currently Im using winding number algorithm,…
user3157855
  • 714
  • 2
  • 9
  • 24
3
votes
2 answers

distance from point to polygon (when inside)

I'm trying to find an efficient way to compute the distance from a point to the nearest edge of a polygon in python. I thought shapely would be perfect for this, but it only computes the distance when the point is outside the polygon. I thought…
user1554752
  • 707
  • 2
  • 10
  • 24
3
votes
2 answers

Including edges in this pnpoly algorithm

I have this point in polygon function to use in my pathfinding program. int point_in_pol(int vertcount, float *vertx, float *verty, int vertexx, int vertexy){ double vertexx1; vertexx1 = vertexx; double vertexy1; vertexy1 =…
gkhnavarro
  • 446
  • 2
  • 14
3
votes
2 answers

How to check if point is in polygon in Javascript

I came across this piece of C code (I think) that's supposed to be a neat way to check if a point is within a concave or convex polygon, and I would like to convert it to a JS equivalent function to use in my JS program: int pnpoly(int nvert, float…
Henrik
  • 673
  • 8
  • 18
2
votes
3 answers

Point-in-Polygon PHP Errors

I am using a point-in-polygon check in php, but I am getting major errors - as in points that are not in the polygon are coming up as inside. My basic functions are typed out below (found here, modified from a class to a simple function:…
dmgig
  • 4,400
  • 5
  • 36
  • 47
2
votes
0 answers

Finding the irregularly-shaped subview that contains a point

My main view has several (perhaps many) polygonal active areas implemented as subviews. When the user touches the view, I want to identify if she hit one of those active areas. Is there anything better than a naive algorithm that would iterate over…
Jean-Denis Muys
  • 6,772
  • 7
  • 45
  • 71
2
votes
1 answer

Points in Polygons. How can I match them spatially with given coordinates?

I have a dataset of georeferenced flickr posts (ca. 35k, picture below) and I have an unrelated dataset of georeferenced polygons (ca. 40k, picture below), both are currently panda dataframes. The polygons do not cover the entire area where flickr…
diana
  • 21
  • 2