[MDAL-Developer] Python-Bindings

Paul Harwood runette at gmail.com
Sat May 29 05:54:28 PDT 2021


I have one generic question - since I am looking at the best way to
generalise Datasets.

One Dataset Group can have multiple Datasets. Is there any occasion other
than temporal data when this happens?

If there is, what is the way to identify the meaning of the datasets. With
temporal data, the different datasets can be identified using the
MDAL_D_time function, but are there other equivalents?

On Sat, 29 May 2021 at 13:50, Paul Harwood <runette at gmail.com> wrote:

> the results from the previous code looks like
>
> """
>
> MDAL Version:  0.8.0
>
> MDAL Driver Count :16
>
> 0
>
> 2DM Mesh File
>
> XMS Tin Mesh File
>
> Selafin File
>
> Esri TIN
>
> Stanford PLY Ascii Mesh File
>
> Flo2D
>
> HEC-RAS 2D
>
> TUFLOW FV
>
> AnuGA
>
> UGRID Results
>
> GDAL NetCDF
>
> GDAL Grib
>
> DAT
>
> Binary DAT
>
> TUFLOW XMDF
>
> XDMF
>
> ['PLY:"data/ply/test_mesh.ply"']
>
> Driver : PLY
>
> Vertex Count : 38487
>
> Face Count : 76294
>
> Largest Face: 3
>
> Edge Count : 0
>
> CRS :
>
> Mesh extent : (413630.0, 416783.0, 379766.0, 382410.0)
>
> DatasetGroup Count : 4
>
>
> Driver : PLY
>
> Vertex Count : 38487
>
> Face Count : 76294
>
> Largest Face: 3
>
> Edge Count : 0
>
> CRS :
>
> Mesh extent : (413630.0, 416783.0, 379766.0, 382410.0)
>
> Vertex Array Shape : (38487,)
>
> Face Array Shape : (76294,)
>
> Edges Array Shape : (0,)
>
>
> DatasetGroup Name : Bed Elevation
>
> DatasetGroup Location : 1
>
> Dataset Count : 1
>
> Group has scalar values : True
>
> Group has temporal values : False
>
> Reference Time :
>
> Maximum Vertical Level Count : 0
>
> Minimum / Maximum ; (178.64, 465.043)
>
> Metadata : {'Bed Elevation': b'Bed Elevation'}
>
>
> Dataset Shape : (38487,)
> """
>
> On Sat, 29 May 2021 at 13:46, Paul Harwood <runette at gmail.com> wrote:
>
>> 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/d3455077/attachment-0001.html>


More information about the MDAL-Developer mailing list