modelgebied Polygon
verfijning Polygon
water Polygon
Read layers from a GeoPackage
Most model input lives in GIS layers. read_domain, read_refinement_areas and read_water_areas read a layer of a GeoPackage or shapefile (with pyogrio; geopandas is not needed) and keep its CRS.
The example GeoPackage model.gpkg has three layers:
Read and generate
from refined_quads import (
generate,
read_domain,
read_refinement_areas,
read_water_areas,
)
domain = read_domain(gpkg, "modelgebied")
areas = read_refinement_areas(gpkg, "verfijning", level="refinement")
water = read_water_areas(gpkg, "water")
quad_mesh = generate(
domain,
cell_size=32.0,
refinement_areas=areas,
transition_rows=1,
water_areas=water,
)
print(quad_mesh)Mesh(nodes=843, faces=912, cell_size=32, levels=2, crs=EPSG:28992)
Rules
- A file with one layer needs no layer name. With several layers the name is required; without it you get an error that lists the layers.
levelis the name of a column with the refinement level per polygon, or one integer for the whole layer (level=3). A missing or invalid level (0, a negative number, 2.5, empty) raises an error that names the feature.- All polygons of the domain layer are merged into one (multi)polygon.
- The mesh gets the CRS of the domain, and other layers are transformed to it. A layer without CRS raises an error unless you pass
crs=for it. A geographic CRS (degrees) for the domain raises an error, as cell sizes must be in metres. - Instead of a path you may pass a GeoDataFrame, or any object with
geometryandcrsattributes:read_refinement_areas(frame, level="refinement"). - Plain shapely geometries have no CRS: pass
crs=togenerate(see the tutorial).