Skip to content
Snippets Groups Projects
Commit 0ce82f4d authored by Mohamed Abdelaziz's avatar Mohamed Abdelaziz
Browse files

Bilder und ein Beishpiel von Orte Innerhalb und Außerhalb Hamburg hizüfugen.

parent 7a622ba0
No related branches found
No related tags found
1 merge request!1Bilder und ein Beishpiel von Orte Innerhalb und Außerhalb Hamburg hizüfugen.
04-raeumliche-daten/Hamburg.png

638 KiB

%% Cell type:markdown id: tags:
# Punkte und Polygone
Ob sich ein Objekt an einem bestimmten Ort aufhält können in der Geometrie als die Frage umformuliert werden, ob sich ein Punkt in einem Polygon befindet.
Dies kann bspw. mit dem Modul `shapely` einfach überprüft werden.
Weitere geometrische Figuren und Methoden sind in der [Dokumentation von shapely](https://shapely.readthedocs.io/en/stable/manual.html) nachlesbar.
%% Cell type:code id: tags:
``` python
from shapely.geometry import Point
from shapely.geometry import Polygon
```
%% Cell type:markdown id: tags:
## Einführendes Beispiel
![title](Quadrat.png)
Zunächst wird ein Punkt und ein Polygon definiert.
Das Polygon entspricht einem Quadrat, der `point_1` liegt genau in der Mitte.
%% Cell type:code id: tags:
``` python
point_1 = Point((.5, .5))
polygon = Polygon(((0, 0), (0, 1), (1, 1), (1, 0)))
```
%% Cell type:markdown id: tags:
Ob sich der Punkt im Polygon befindet, kann über die Methode `contains` abgefragt werden.
%% Cell type:code id: tags:
``` python
polygon.contains(point_1)
```
%% Output
True
%% Cell type:markdown id: tags:
Der nächste Punkt liegt nun eindeutig außerhalb des Quadrats.
%% Cell type:code id: tags:
``` python
point_2 = Point((2, 2))
polygon.contains(point_2)
```
%% Output
False
%% Cell type:markdown id: tags:
![title](Hamburg.png)
Webseite: https://www.keene.edu/campus/maps/tool/
%% Cell type:code id: tags:
``` python
hamburg_rathaus = Point((9.9937391, 53.5513486))
hamburg = Polygon(((10.23, 53.62), (10.21, 53.75), (9.93, 53.67), (9.72, 53.63), (9,72, 53.5), (10, 53.4), (10.26, 53.47), (10.23, 53.62)))
```
%% Cell type:code id: tags:
``` python
hamburg.contains(hamburg_rathaus)
```
%% Output
True
%% Cell type:code id: tags:
``` python
bremen = Point((8.8014221, 53.0756713))
hamburg.contains(bremen)
```
%% Output
False
......
04-raeumliche-daten/Quadrat.png

5.37 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment