gemgis.vector.extract_xy_from_polygon_intersections
gemgis.vector.extract_xy_from_polygon_intersections#
- gemgis.vector.extract_xy_from_polygon_intersections(gdf: geopandas.geodataframe.GeoDataFrame, extract_coordinates: bool = False, drop_index: bool = True) geopandas.geodataframe.GeoDataFrame #
Calculating the intersections between Polygons; the table must be sorted by stratigraphic age
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing Polygons of a geological map ordered by their stratigraphic age
extract_coordinates (bool) – Variable to extract X and Y coordinates from resulting Shapely Objects. Options include:
True
orFalse
, default set toFalse
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
- Returns
intersections – GeoDataFrame containing the intersections of the polygons of a geological map
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Polygon >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> import geopandas as gpd >>> 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 GeoDataFrame from polygons and adding formation names >>> gdf = gpd.GeoDataFrame(geometry=[polygon1, polygon2]) >>> gdf['formation'] = ['Formation1', 'Formation2'] >>> gdf geometry formation 0 POLYGON (((0 0, 10 0, 10 10, 0 10, 0 0)) Formation1 1 POLYGON ((10 0, 20 0, 20 10, 10 10, 10 0)) Formation2
>>> # Extracting X an Y coordinates from polygon intersections >>> intersection = gg.vector.extract_xy_from_polygon_intersections(gdf=gdf) >>> intersection formation geometry 0 Formation1 LINESTRING (10.0 0.0, 10.0 10.0)
See also
intersection_polygon_polygon
Intersecting a polygon with a polygon
intersections_polygon_polygons
Intersecting a polygons with multiple polygons
intersections_polygons_polygons
Intersecting multiple polygons with multiple polygons