gemgis.vector.intersection_polygon_polygon
gemgis.vector.intersection_polygon_polygon#
- gemgis.vector.intersection_polygon_polygon(polygon1: shapely.geometry.polygon.Polygon, polygon2: shapely.geometry.polygon.Polygon) Union[shapely.geometry.linestring.LineString, shapely.geometry.polygon.Polygon] #
Calculating the intersection between to Shapely Polygons
- Parameters
polygon1 (shapely.geometry.polygon.Polygon) – First polygon used for intersecting, e.g.
polygon1=Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]])
polygon2 (shapely.geometry.polygon.Polygon) – Second polygon used for intersecting, e.g.
polygon2=Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]])
- Returns
intersection – Intersected geometry as Shapely Object
- Return type
Union[shapely.geometry.linestring.LineString, shapely.geometry.polygon.Polygon]
New in version 1.0.x.
Example
>>> # Loading Libraries >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> polygon1 = Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]) >>> polygon1.wkt 'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'
>>> # Creating second Polygon >>> polygon2 = Polygon([[10, 0], [20, 0], [20, 10], [10, 10], [10, 0]]) >>> polygon2.wkt 'POLYGON ((10 0, 20 0, 20 10, 10 10, 10 0))'
>>> # Calculating the intersection between two polygons >>> intersection = gg.vector.intersection_polygon_polygon(polygon1=polygon1, polygon2=polygon2) >>> intersection.wkt 'LINESTRING (10 0, 10 10)'
See also
intersections_polygon_polygons
Intersecting a polygon with mutiple polygons
intersections_polygons_polygons
Intersecting multiple polygons with multiple polygons
extract_xy_from_polygon_intersections
Extracting intersections between multiple polygons