OpenGeoVis / omfvista

3D visualization for the Open Mining Format (omf)

Home Page:https://opengeovis.github.io/omfvista/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OMF Tutorial file can not be loaded

Terranigmus opened this issue · comments

Created the tutorial file found here:

https://omf.readthedocs.io/en/latest/content/examples.html

Tried to read the project, results in

AttributeError: 'SurfaceGridGeometry' object has no attribute 'vertices'

File attached
omftest.txt

Thanks for raising this issue, @Terranigmus. I'm not exactly sure whats happening for you... I ran your script on my end with no issue, then built a test case (added in ad2634a) using the same code which is successfully running on Travis.

To better track down what is happening on your end, can you please share the following:

  • Operating System (e.g. Mac OS, Linux, Windows)
  • System Architecture (e.g. 32, 64)
  • Python version (e.g. 2.7, 3.6)
  • Version of OMF (e.g. 1.0.0 Note: omfvtk requires 1.0.0 of omf)
  • Version of omfvtk (e.g. the latest version: 0.0.6)
  • Was omfvtk installed from pip or from source?
  • Was omf installed from pip or from source?

Also, could you please post the full traceback leading up to AttributeError: 'SurfaceGridGeometry' object has no attribute 'vertices'

Sure!

runfile('C:/Users/Paul/Nextcloud/Programing/omftest/omftest.py', wdir='C:/Users/Paul/Nextcloud/Programing/omftest')
Traceback (most recent call last):

  File "<ipython-input-10-93bb4e483018>", line 1, in <module>
    runfile('C:/Users/Paul/Nextcloud/Programing/omftest/omftest.py', wdir='C:/Users/Paul/Nextcloud/Programing/omftest')

  File "C:\Users\Paul\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 704, in runfile
    execfile(filename, namespace)

  File "C:\Users\Paul\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/Paul/Nextcloud/Programing/omftest/omftest.py", line 155, in <module>
    proj=omfvtk.load_project('omfproj.omf')

  File "C:\Users\Paul\Anaconda3\lib\site-packages\omfvtk\wrapper.py", line 124, in load_project
    return project_to_vtk(project)

  File "C:\Users\Paul\Anaconda3\lib\site-packages\omfvtk\wrapper.py", line 115, in project_to_vtk
    d = omfvtk.wrap(e)

  File "C:\Users\Paul\Anaconda3\lib\site-packages\omfvtk\wrapper.py", line 103, in wrap
    return wrappers[key](data)

  File "C:\Users\Paul\Anaconda3\lib\site-packages\omfvtk\surface.py", line 78, in surface_to_vtk
    output = surface_geom_to_vtk(surfel.geometry)

  File "C:\Users\Paul\Anaconda3\lib\site-packages\omfvtk\surface.py", line 34, in surface_geom_to_vtk
    pts.SetData(nps.numpy_to_vtk(surfgeom.vertices))

AttributeError: 'SurfaceGridGeometry' object has no attribute 'vertices'

Could you post your system details as listed in the above post?

Outlined in the docs for OMF, vertices is a required property of SurfaceGridGeometry. This leads me to believe you have an out dated version of OMF.

Could you specifically share your version of OMF (pip show omf) or try upgrading OMF (pip install -U omf)

Operating System : Windows 10 64bit
Python version  3.6
Version of OMF 1.0.0
Version of omfvtk : latest
omfvtk installed from pip

The culprit is the grid element in the API tutorial script.
The "geometry" element is set from omf.SurfaceGridGeometry(), which does NOT require the vertices!
I think you are looking at SurfaceGeometry

grid = omf.SurfaceElement(
    name='gridsurf',
    **geometry=omf.SurfaceGridGeometry(
        tensor_u=np.ones(10).astype(float),
        tensor_v=np.ones(15).astype(float),
        origin=[50., 50., 50.],
        axis_u=[1., 0, 0],
        axis_v=[0, 0, 1.],
        offset_w=np.random.rand(11, 16).flatten()
    ),**
    data=[
        omf.ScalarData(
            name='rand vert data',
            array=np.random.rand(11, 16).flatten(),
            location='vertices'
        ),
        omf.ScalarData(
            name='rand face data',
            array=np.random.rand(10, 15).flatten(order='f'),
            location='faces'
        )
    ],
    textures=[
        omf.ImageTexture(
            name='test image',
            image='test_image.png',
            origin=[2., 2., 2.],
            axis_u=[5., 0, 0],
            axis_v=[0, 2., 5.]
        )
    ]
)

Could it be that omfvtk does not detect that change and thus asks for the "vertices" attribute?

Just to follow up on this - @banesullivan, looks like here the code assumes the surface geometry is always SurfaceGeometry so SurfaceGridGeometry fails: https://github.com/OpenGeoVis/omfvtk/blob/master/omfvtk/surface.py#L78

I suspect this is just because the support for Surface Grids isn't implemented yet: https://github.com/OpenGeoVis/omfvtk/blob/master/omfvtk/surface.py#L52

Would certainly be nice, I am trying to develop an integration into QGIS for Archaeological data exchange, which is in essence a boatload of georeferenced handdrawn pictures.

Ah, thanks for investigating @fwkoch! I see what's going on here now... This should be an easy fix and I can implement functionality for SurfaceGridGeometry sometime today for you @Terranigmus.

I am trying to develop an integration into QGIS for Archaeological data exchange, which is in essence a boatload of georeferenced handdrawn pictures.

@Terranigmus, this sounds cool! Are you writing a way to put that data standard into the OMF specification? or how are you approaching this?

It's more that this format is a very good exchange standard itself, textured surfaces. A friend of mine has big problems because Government requires documentation "in an open GIS format" and for some stupid reason chose "shapefile" which results in quite some chaos here.
Basically trying to explore if using OMF as saving format and the VTK stuff for QGIS is feasible.
Haven't totally thought this through though.

Often archaeological diggs also involve Mag and sometimes ERT so the standard provides me with all that I need while still hopefully being supported by Oasis Montaj/Seequent soonish which is the defacto industry standard for Geophysics

@Terranigmus - Really cool to hear! Feel free to open issues on the OMF github repo if there is some specific support missing. There is a meeting at the beginning of March to make some decisions around OMF v2, and it's nice to have input from a variety of use cases - https://github.com/gmggroup/omf/issues?q=is%3Aissue+is%3Aopen+label%3A%22OMF+v2+Proposal%22

Fixed in v0.0.7