export as csv

Issue #13 resolved
Eike Lie created an issue

Hi,

I would like to export my scatter plot as csv, so that I can overlay different scenes in excel. for some reason it didn’t work and no clue why.

2020-10-18T15:41:41     WARNING    Traceback (most recent call last):
              File "C:/Users/Eike/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\rasterdataplotting\rasterdataplotting\site\pyqtgraph\exporters\Exporter.py", line 77, in fileSaveFinished
              self.export(fileName=fileName, **self.fileDialog.opts)
              File "C:/Users/Eike/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\rasterdataplotting\rasterdataplotting\site\pyqtgraph\exporters\CSVExporter.py", line 62, in export
              numRows = max([len(d[0]) for d in data])
             ValueError: max() arg is an empty sequence

Other question: How to show the third axis for value density? can’t find it.

Comments (4)

  1. Andreas Janz repo owner

    Unfortunately, the CSV export is part of the plotting package (pyqtgraph) and not under my control. It seams that only vector plots (e.g. point and line plots) are exported and not images like the 2d-density.

    Having said that, I think I could give you a code snipped, that you can execute in the QGIS Python Consol, that dumps the current data into a csv file.

    Would that be helpful?

  2. Eike Lie reporter

    ok, I will try this 🙏

    can I alter the code by myself for further images? dont want to hold you up..

  3. Andreas Janz repo owner

    This will export the density rgb image to 3 CVS files for red, green and blue.

    import rasterdataplotting, numpy
    rgba = rasterdataplotting.rdpInterface().ui.ui.scatterPlot().ui.imageView().renderedImage()
    print(rgba.shape)
    for i, channel in enumerate(['red', 'green', 'blue']):
        numpy.savetxt(rf'c:\_test\density_{channel}.csv', rgba[:,:,channel])
    

    Is that sufficieant?

  4. Log in to comment