gemgis.vector.intersections_polygon_polygons#

gemgis.vector.intersections_polygon_polygons(polygon1: shapely.geometry.polygon.Polygon, polygons2: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]]) List[shapely.geometry.base.BaseGeometry]#

Calculating the intersections between one polygon and a list of 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]])

  • polygons2 (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]]) – List of polygons as list or GeoDataFrame to get intersected

Returns

intersections – List of intersected geometries

Return type

List[shapely.geometry.base.BaseGeometry]

New in version 1.0.x.

Example

>>> # Loading Libraries and creating Polygon
>>> 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))'
>>> # Creating list of polygons
>>> polygons2 = [polygon2, polygon2]
>>> # Calculating the intersections between a polygon with polygons
>>> intersection = gg.vector.intersections_polygon_polygons(polygon1=polygon1, polygons2=polygons2)
>>> intersection
[<shapely.geometry.linestring.LineString at 0x231eaf22100>,
<shapely.geometry.linestring.LineString at 0x231eab22970>]
>>> # Inspecting the first element of the list
>>> intersection[0].wkt
'LINESTRING (10 0, 10 10)'
>>> # Creating the second element of the list
>>> intersection[1].wkt
'LINESTRING (10 0, 10 10)'

See also

intersection_polygon_polygon

Intersecting a polygon with a polygon

intersections_polygons_polygons

Intersecting multiple polygons with multiple polygons

extract_xy_from_polygon_intersections

Extracting intersections between multiple polygons