Skip to main content

Meshing a GeoDataFrame using Gmsh.

Project description

https://raw.githubusercontent.com/cheginit/geomesher/main/doc/source/_static/logo-text.png

GeoMesher: Meshing a GeoDataFrame using Gmsh

CI PyPi Conda Version CodeCov Python Versions

Downloads CodeFactor black pre-commit

Features

GeoMesher is a fork of pandamesh. The original package included two mesh generators: Triangle and Gmsh. This fork only includes the Gmsh mesh generator since Triangle seems to be not maintained anymore. Also, GeoMesher adds the following new functionalities:

  • A new method for returning the generated mesh as a GeoDataFrame.

  • A new function called gdf_mesher that can generate a mesh from a GeoDataFrame with a single function call and with sane defaults for the mesh generator.

  • Remap a scalar field from the source GeoDataFrame to the generated mesh, using an area weighted interpolation method (based on Tobler).

  • Handle MultiPolygon geometries in the source GeoDataFrame.

Note that the remapping functionality of GeoMesher is a simple areal interpolation method. For more advanced interpolation methods, please use Tobler.

Installation

You can install GeoMesher using pip:

$ pip install geomesher

or using conda (mamba):

$ conda install -c conda-forge geomesher

Quick start

The following example shows how to generate a mesh from a GeoDataFrame using both the gdf_mesher function and the Mesher class.

We start by getting a GeoDataFrame of South America from the Natural Earth website. Then, we reproject it to a projected coordinate system (UTM zone 20S). Finally, we add a new column called cellsize that will be used to set the maximum size of the mesh elements.

We use the gdf_mesher function to generate the mesh with default parameters and use Mesher to generate the mesh with MESH_ADAPT algorithm. We also use the area_interpolate function to remap the POP_EST column from the source GeoDataFrame to the generated mesh.

import geopandas as gpd
import geomesher as gm

world = gpd.read_file(
    "https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip"
)

south_america = world[world["CONTINENT"] == "South America"]
south_america = south_america.explode(ignore_index=True).to_crs(32620)
south_america["cellsize"] = 500_000.0

mesh_auto = gm.gdf_mesher(south_america, intensive_variables=["POP_EST"])

mesher = gm.Mesher(south_america)
mesher.mesh_algorithm = "MESH_ADAPT"
mesh_adapt = mesher.generate()
mesh_adapt = gm.area_interpolate(south_america, mesh_adapt, intensive_variables=["POP_EST"])
https://raw.githubusercontent.com/cheginit/geomesher/main/doc/source/_static/demo.png

Contributing

Contributions are very welcomed. Please read CONTRIBUTING.rst file for instructions.

Credits

GeoMesher is a fork of pandamesh (MIT License) and uses one of the modules in Tobler (BSD-3-Clause License).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geomesher-0.1.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

geomesher-0.1.0-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file geomesher-0.1.0.tar.gz.

File metadata

  • Download URL: geomesher-0.1.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for geomesher-0.1.0.tar.gz
Algorithm Hash digest
SHA256 049218ad13f42f7d223a8526acd0b516f98fb6ad8b24df31d1e7f960a9a00e4c
MD5 1430e26e06b9de4a5a98c378b72b5e80
BLAKE2b-256 1146961f992e44af753658acd88ca0bc244de7804e386704e3d7aea7095b3ce6

See more details on using hashes here.

File details

Details for the file geomesher-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: geomesher-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for geomesher-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c32143b6117dd71de6e4d8fe2ba6e0a47fe387fb96b00bb8dacd6231edb91634
MD5 5816ff08b814b94af15fdde03a505fe7
BLAKE2b-256 64b9d51c5e2cd76fe43ba6066feec05a5b6977a3346dc0f7b157b3c53609bf6a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page