K
K
Kirill Kudryavtsev2018-11-24 13:24:14
Python
Kirill Kudryavtsev, 2018-11-24 13:24:14

How to determine the presence of a point inside a polygon?

There are two polygons, you need to determine whether the point is in the polygon or not.
What is currently done is to determine if a point is or not in a simple polygon (without overlapping itself). How can you determine if a point is overlapping itself using numpy/matplot.
Create polygons:

from matplotlib.patches import Polygon
polygons = [
    {
        'label': 'first',
        'cors': [
            [0.85157715, 0.53259596],
            [0.47351539, 0.78381185],
            [0.63767088, 0.07172642]
        ]
    },
    {
        'label': 'second',
        'cors': [
            [0.82024332, 0.60039117],
            [1, 1.80039117],
            [1.19215456, 0.62590895],
            [1.4, 0.81912354],
            [0.83599825, 1.12872215]
        ]
    }
]
for poly in polygons:
    polygon = Polygon(poly['cors'], False)
    polygon.set_label(poly['label'])
    patches.append(polygon)

Output example
5bf92676dbb7d258830883.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
d0lph1n, 2018-11-25
@Deissh

https://ru.wikipedia.org/wiki/%D0%97%D0%B0%D0%B4%D...
https://habr.com/post/301102/
https://habr.com/post /125356/

V
Vadim Shatalov, 2018-11-25
@netpastor

https://github.com/Toblerity/Shapely

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question