From geodataframe to mesh
Project description
This package translates geospatial vector data (points, lines, or polygons) to unstructured meshes.
import pandamesh as pm
# 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.0
mesher = pm.TriangleMesher(south_america)
vertices, faces = mesher.generate()
The package converts geospatial data, presented as geopandas GeoDataFrames, to unstructured meshes using the open source high quality mesh generators:
utilizing the respective Python API’s, available at:
For completeness, the source code of both projects can be found at:
https://gitlab.onelab.info/gmsh/gmsh, under api/gmsh.py
These APIs are wrapped in two lightweight classes: pandamesh.TriangleMesher and pandamesh.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 is usual for 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.
Installation
pip install pandamesh
Documentation
The documentation can be found here.
Other projects
Pandamesh 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 also this list for many other mesh generation tools.
pygmsh
The pygmsh Python package provides 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-gsmh
qgis-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.002
Shingle
Shingle 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-2018
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pandamesh-0.2.2.tar.gz
.
File metadata
- Download URL: pandamesh-0.2.2.tar.gz
- Upload date:
- Size: 46.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f47316bf1d20c1488a7a78d19ab46e61d97f8d90ef8d6b6c791cc94e5d9d1a19 |
|
MD5 | 5ba43d75a611e1026cea8508a7b05531 |
|
BLAKE2b-256 | 4b17ba252cd3addd9b5a31e14f2013214444b9331a761a0809398c95026478c4 |
File details
Details for the file pandamesh-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: pandamesh-0.2.2-py3-none-any.whl
- Upload date:
- Size: 40.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 519afc3d76052c44428b11cd1b118630a1f202582425406bde24ffa79efd6039 |
|
MD5 | cdddde8a7f757a3e0054292fe0c88bdf |
|
BLAKE2b-256 | 5f85983186963e7574aaaf2da8afae214ac7358ed6bab72d0e2fab474db94418 |