[MDAL-Developer] Python-Bindings

Paul Harwood runette at gmail.com
Sat May 29 05:46:21 PDT 2021


As promised - I have been working on some Python Bindings. I now have a
0.9.0b1 type release :

See https://github.com/ViRGIS-Team/mdal-python

There is a conda install for this in the process of being created.

There is some documentation in the process of being created.

Currently, this integration can:

- read all MDAL compatible file formats,
- access the metadata for the source,
- access the vertex, face and edge data as NumPy arrays,
- access 'double' datasets (both scalar and vector) as NumPy arrays, and
- convert the MDAL source mesh into a meshio mesh object (with some
restrictions currently).
- This version does not currently allow the MDAL source mesh to be written
or amended.

Note this very much beta and has not been comprehensively tested. The
following script has been run successfully on a number of different test
files and shows the usage.

All comments and improvements welcome.

"""

import mdalfrom mdal import Datasource
print(f"MDAL Version:  {mdal.getVersionString()}")print(f"MDAL Driver
Count :{mdal.getDriverCount()}")print(mdal.getLastStatus())
for driver in mdal.getDrivers():
    print(driver.long_name)

ds = Datasource("data/ply/test_mesh.ply")print(ds.meshes)
mesh = ds.load(0)print(f"Driver : {mesh.driverName}")print(f"Vertex
Count : {mesh.vertexCount}")print(f"Face Count :
{mesh.faceCount}")print(f"Largest Face:
{mesh.largestFace}")print(f"Edge Count : {mesh.edgeCount}")print(f"CRS
: {mesh.projection}")print(f"Mesh extent :
{mesh.extent}")print(f"DatasetGroup Count :
{mesh.groupCount}")print("")
mesh = ds.load(ds.meshes[0])print(f"Driver :
{mesh.driverName}")print(f"Vertex Count :
{mesh.vertexCount}")print(f"Face Count :
{mesh.faceCount}")print(f"Largest Face:
{mesh.largestFace}")print(f"Edge Count : {mesh.edgeCount}")print(f"CRS
: {mesh.projection}")print(f"Mesh extent : {mesh.extent}")
vertex = mesh.getVertices()print(f"Vertex Array Shape : {vertex.shape}")
faces = mesh.getFaces()print(f"Face Array Shape : {faces.shape}")
edges = mesh.getEdges()print(f"Edges Array Shape : {edges.shape}")
print("")
group = mesh.getGroup(0)print(f"DatasetGroup Name :
{group.name}")print(f"DatasetGroup Location :
{group.location}")print(f"Dataset Count :
{group.datasetCount}")print(f"Group has scalar values :
{group.hasScalar}")print(f"Group has temporal values :
{group.isTemporal}")print(f"Reference Time :
{group.referenceTime}")print(f"Maximum Vertical Level Count :
{group.levelCount}")print(f"Minimum / Maximum ;
{group.minmax}")print(f"Metadata : {group.getMetadata()}")
print("")
data = group.getDataAsDouble(0)print(f"Dataset Shape : {data.shape}")

"""
(see next email to see results from this code)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mdal-developer/attachments/20210529/47ff2eaa/attachment.html>


More information about the MDAL-Developer mailing list