gemgis.vector.create_polygons_from_faces
gemgis.vector.create_polygons_from_faces#
- gemgis.vector.create_polygons_from_faces(mesh: pyvista.core.pointset.PolyData, crs: Union[str, pyproj.crs.crs.CRS], return_gdf: bool = True) Union[List[shapely.geometry.polygon.Polygon], geopandas.geodataframe.GeoDataFrame] #
Extracting faces from PyVista PolyData as Shapely Polygons
- Parameters
mesh (pv.core.pointset.PolyData) – PyVista PolyData dataset
crs – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
crs='EPSG:4647'
- Returns
polygons – Triangular Shapely Polygons representing the faces of the mesh
- Return type
Union[List[shapely.geometry.polygon.Polygon], gpd.geodataframe.GeoDataFrame]
New in version 1.0.x.
Example
>>> # Importing Libraries and File >>> import gemgis as gg >>> import pyvista as pv >>> mesh = pv.read(filename='mesh.vtk') >>> mesh Header PolyData Information N Cells 29273 N Points 40343 X Bounds 2.804e+05, 5.161e+05 Y Bounds 5.640e+06, 5.833e+06 Z Bounds -8.067e+03, 1.457e+02 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Depth [m] Points float64 1 -8.067e+03 1.457e+02
>>> # Create polygons from mesh faces >>> polygons = gg.vector.create_polygons_from_faces(mesh=mesh) >>> 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...