Package: pandamesh
This package translates geospatial vector data (points, lines, or polygons) to
unstructured meshes.importpandameshaspm# Get some sample data in geopandas form.south_america=pm.data.south_america()# Explode any multi-polygon, and project it to UTM20.south_america=south_america.explode(index_parts=True).reset_index().to_crs(epsg=32620)# Set a maximum cell size of 500 km and generate a mesh.south_america["cellsize"]=500_000.0mesher=pm.TriangleMesher(south_america)vertices,faces=mesher.generate()The package converts geospatial data, presented asgeopandasGeoDataFrames, to unstructured meshes using the open source
high quality mesh generators:Christophe Geuzaine and Jean-François Remacle’sGmshJonathan Shewchuk’sTriangleutilizing the respective Python API’s, available at:https://pypi.org/project/gmsh/https://pypi.org/project/triangle/For completeness, the source code of both projects can be found at:https://gitlab.onelab.info/gmsh/gmsh, underapi/gmsh.pyhttps://github.com/drufat/triangleThese APIs are wrapped in two lightweight classes:pandamesh.TriangleMesherandpandamesh.GmshMesher. Both are initialized with a GeoDataFrame defining
the geometry features of the mesh. During initialization, geometries are
checked for overlaps and intersections, as the mesh generators cannot deal with
these.  Generated meshes are returned as two numpy arrays: the coordinates of
the vertices, and the connectivity of the mesh faces to these vertices (as isusualfor many unstructured grid representations).GeoPandas is not suited for geometries that “wrap around” the world.
Consequently, this package cannot generate meshes for e.g. a sphere.Installationpip install pandameshDocumentationThe documentation can be foundhere.Other projectsPandamesh has been developed because none of the existing packages provide a
straightforward scripting based approach to converting 2D vector geometries to
2D unstructured grids.Examples of other packages which work with unstructured meshes are listed below.See alsothis listfor many other mesh generation tools.pygmshThepygmsh Python packageprovides useful abstractions from Gmsh’s own
Python interface so you can create complex geometries more easily. It also
provides tools for 3D operations (e.g. extrusions).qgis-gsmhqgis-gmsh generates geometry input files for the GMSH mesh generator and
converts the Gmsh mesh files to shapefiles that can be imported into QGIS.Lambrechts, J., Comblen, R., Legat, V., Geuzaine, C., & Remacle, J. F. (2008).
Multiscale mesh generation on the sphere. Ocean Dynamics, 58(5-6), 461-473.Remacle, J. F., & Lambrechts, J. (2018). Fast and robust mesh generation on
the sphere—Application to coastal domains. Computer-Aided Design, 103, 14-23.https://doi.org/10.1016/j.cad.2018.03.002Source:https://github.com/ccorail/qgis-gmshShingleShingle provides generalised self-consistent and automated domain
discretisation for multi-scale geophysical models.Candy, A. S., & Pietrzak, J. D. (2018). Shingle 2.0: generalising
self-consistent and automated domain discretisation for multi-scale
geophysical models. Geoscientific Model Development, 11(1), 213-234.https://doi.org/10.5194/gmd-11-213-2018Source:https://github.com/shingleproject/ShingleWebsite:http://shingleproject.org/index_shingle1.0.html