gemgis.vector.intersections_polygons_polygons
gemgis.vector.intersections_polygons_polygons#
- gemgis.vector.intersections_polygons_polygons(polygons1: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]], polygons2: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]]) List[shapely.geometry.base.BaseGeometry] #
Calculating the intersections between a list of Polygons
- Parameters
polygons1 (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]]) – List of Polygons or GeoDataFrame containing Polygons to be intersected
polygons2 (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]]) – List of Polygons or GeoDataFrame containing Polygons to be 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 list of polygons >>> polygons1 = [polygon1, polygon1]
>>> # 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 intersections between polygons and polygons >>> intersection = gg.vector.intersections_polygons_polygons(polygons1=polygons1, polygons2=polygons2) >>> intersection [<shapely.geometry.linestring.LineString at 0x231eaf4dd90>, <shapely.geometry.linestring.LineString at 0x231ec6e8df0>, <shapely.geometry.linestring.LineString at 0x231eaf4dc70>, <shapely.geometry.linestring.LineString at 0x231eaf4dd00>]
>>> # Inspecting the first element of the list >>> intersection[0].wkt 'LINESTRING (10 0, 10 10)'
>>> # Inspecting the second element of the list >>> intersection[1].wkt 'LINESTRING (10 0, 10 10)'
>>> # Inspecting the third element of the list >>> intersection[2].wkt 'LINESTRING (10 0, 10 10)'
>>> # Inspecting the fourth element of the list >>> intersection[3].wkt 'LINESTRING (10 0, 10 10)'
See also
intersection_polygon_polygon
Intersecting a polygon with a polygon
intersections_polygon_polygons
Intersecting a polygons with multiple polygons
extract_xy_from_polygon_intersections
Extracting intersections between multiple polygons