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.
Questions tagged [point-in-polygon]
275 questions
4
votes
2 answers
Point in Polygon Hit Test in JavaScript (Chrome bug)
I am working on a game written in javaScript / jQuery. Part of my code draws a random polygon (an island) on a tile grid. I need to check if a point is inside the polygon.
I am using a point-in-polygon intersection script which I found in several…

shipshape
- 1,682
- 2
- 17
- 33
4
votes
5 answers
Point in rectangle
What is the fastest way to find if a point is in a rectangle given in this form:
I have two points which are the centers of opposite sides of the rectangle, and a number which is the height of those sides. I hope this is clear.
The rectangle is…

Baruch
- 20,590
- 28
- 126
- 201
4
votes
1 answer
Why is Triangle.Net not triangulating these polygons as expected?
I've been having issues with triangulating certain polygons with holes using Triangle.Net.
The issue seems to be certain circumstances where I define a hole using a contour and setting hole to 'true' (after first adding the outer contour, hole set…

Mark C
- 43
- 4
4
votes
1 answer
Testing whether a 3D point is inside a 3D polyhedron
Given a 3D polyhedron defined by its boundary represented by a triangulated mesh, how can I implement an algorithm that determines whether a given 3D point belongs to the interior of the polyhedron ?

isifzade
- 480
- 1
- 5
- 16
4
votes
1 answer
python: turn polygon into mask array
I have a polygon which I want to turn into a mask array, such that all points that fall inside/outside the polygon are True/False. I thought I found the perfect solution (SciPy Create 2D Polygon Mask), but for some reason this doesn't work!
What am…

flotzilla
- 1,181
- 1
- 13
- 23
4
votes
3 answers
Deciding if a Point is Inside a Polygon
I am trying to detect if a given point(x,y) is in a polygon of n*2 array. But it seems that some points on the borders of the polygon return that it's not include.
def point_inside_polygon(x,y,poly):
n = len(poly)
inside =False
p1x,p1y…

Rabih Assaf
- 95
- 1
- 1
- 8
4
votes
3 answers
Finding if point is in 3D poly in python
I am trying to find out whether a point is in a 3D poly. I had used another script I found online to take care of a lot of the 2D problems using ray casting. I was wondering how this could be changed to work for 3D polygons. I'm not going to be…

fatalaccidents
- 192
- 1
- 2
- 13
4
votes
1 answer
Point in polygon algorithm for SQL Server
I'm trying to write a SQL query which determine if a given point is into a polygon. (I'm using SQL Server 2008 R2).
I was following this tutorial (just copy / paste it and change some table name) and it approximatively works BUT it is not precise…

AlexB
- 7,302
- 12
- 56
- 74
4
votes
2 answers
CGAL tools: is there an interface to CGAL, or equivalent toolset in R?
I'm starting to learn about dealing with complex vs simple polygons, determining whether points are inside/outside polygons, etc. (e.g. http://geomalgorithms.com/a09-_intersect-3.html and related pages). I was hoping to find an R package that…

Carl Witthoft
- 20,573
- 9
- 43
- 73
4
votes
1 answer
check if a point is in a polygon which is partially open
I would like to see if a point is in a polygon or not.
Of course I googled and looked if this question was answered earlier and then found this algorithm: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
This works fine unless…

Folkert van Heusden
- 433
- 4
- 17
- 38
3
votes
3 answers
Determine if a latitude/longitude is within a polygon on Earth's surface
I am trying to figure out if a latitude/longitude point is contained within a polygon defined by vertexes that represent points on the earth (also lat/lon's, in clockwise order). This is trivial for polygons that can be mapped to the 2D lat/lon…

BigBrownBear00
- 1,378
- 2
- 14
- 24
3
votes
1 answer
What would make the point in polygon algorithm only work correctly when run in both forward and reverse?
The most popular answer I found for "point in polygon algorithm for c++" seems to be this C algorithm:
https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html
However, when I implemented this in my program, it was not able to work correctly for…

Bruce Kirkpatrick
- 269
- 3
- 6
3
votes
2 answers
Find in which polygon a GeoJSON point lies in, in NodeJS
Given a defined (lat, lon) geo-point I'm trying to find in which polygon this point lies in. I suppose iterating over all the polygons is not efficient. Is there available any function or library for NodeJS that does this?
const polygon =…

João Pimentel Ferreira
- 14,289
- 10
- 80
- 109
3
votes
1 answer
Does Redis geo have the capability for storing polygon?
I followed several example about geospatial support in Redis. I tried to add POINT features to my Redis dataset without any problem, and subsequently I can query POINT names within certain radius (in meters, km, miles) of a certain coordinate (or a…

Rino
- 131
- 1
- 4
3
votes
0 answers
Change the position of points inside a polygon with Shapely in Python
I want to change by a little the position of some points that are randomly generated inside a Shapely polygon and so far what I use is this:
point_on_polygon = False
while point_on_polygon == False:
y=uniform(0,1)
…

tzoukritzou
- 337
- 1
- 4
- 16