gemgis.vector.unify_polygons#

gemgis.vector.unify_polygons(polygons: Union[List[shapely.geometry.polygon.Polygon], geopandas.geodataframe.GeoDataFrame], crs: Union[str, pyproj.crs.crs.CRS] = None, return_gdf: bool = True) Union[List[shapely.geometry.polygon.Polygon], geopandas.geodataframe.GeoDataFrame]#

Unifying adjacent triangular polygons to form larger objects

Parameters
  • polygons (Union[List[shapely.geometry.polygon.Polygon], gpd.geodataframe.GeoDataFrame]) – Triangular Shapely Polygons representing the faces of the mesh

  • crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g. crs='EPSG:4647'

  • return_gdf (bool) – Variable to either return the data as GeoDataFrame or as list of LineStrings. Options include: True or False, default set to True

Returns

polygons_merged – Merged Shapely Polygons

Return type

Union[List[shapely.geometry.polygon.Polygon], gpd.geodataframe.GeoDataFrame]

New in version 1.0.x.

Example

>>> # Loading Libraries and File
>>> import gemgis as gg
>>> import geopandas as gpd
>>> polygons = gpd.read_file(filename='file.shp')
>>> polygons
    geometry
0   POLYGON Z ((297077.414 5677487.262 -838.496, 2...
1   POLYGON Z ((298031.070 5678779.547 -648.688, 2...
2   POLYGON Z ((297437.539 5676992.094 -816.608, 2...
3   POLYGON Z ((298031.070 5678779.547 -648.688, 2...
4   POLYGON Z ((295827.680 5680951.574 -825.328, 2...
>>> # Merging polygons
>>> polygons_merged = gg.vector.unify_polygons(polygons=polygons)
>>> polygons_merged
    geometry
0   POLYGON Z ((396733.222 5714544.109 -186.252, 3...
1   POLYGON Z ((390252.635 5712409.037 -543.142, 3...
2   POLYGON Z ((391444.965 5710989.453 -516.000, 3...
3   POLYGON Z ((388410.007 5710903.900 -85.654, 38...
4   POLYGON Z ((384393.963 5714293.104 -614.106, 3...