5

I have used the plugin "topology checker" and I got table with all the topology errors : enter image description here

I would like to save this table as new layer/ csv or any way I can export it.

I saw there were disccussion about it few years ago in github but couldn't find any feature to do that.

Is there any way to export this table?

3
  • As far as I know there is no way to export the results of topology checker as CSV or shapefile. I doubt you can even copy and paste the data into text editor, but try to do that for confirmation.
    – ahmadhanb
    Aug 23, 2020 at 7:49
  • @ahmadhanb I couldn't copy it
    – Reut
    Aug 23, 2020 at 7:59
  • Then, I don’t think there is a way to do what you want.
    – ahmadhanb
    Aug 23, 2020 at 8:22

1 Answer 1

7

Here is a bit of a hack I came up with which should do what you want. With the Topology Checker dock widget open and the table populated with some errors, open the Python console, paste the following code into an editor and run. Note* the only thing you need to do is edit the third line of the script to specify the file path to the location where you want the output CSV to be created and what you want it to be named.

Enjoy!

import csv

# Edit line below for your desired output location (the csv will be created)
out_path = 'C:\\Users\\Name\\Desktop\\Topology_errors.csv' # example

check_dock = iface.mainWindow().findChild(QDockWidget, 'checkDock')
main_widget = check_dock.findChild(QWidget, 'dockWidgetContents')
tbl = main_widget.findChild(QTableView, 'mErrorTableView')
out_file = open(out_path, 'w', newline='')

def export_errors(table, output):
    writer = csv.writer(output)
    mod = table.model()
    num_rows = mod.rowCount()
    num_cols = mod.columnCount()
    headers = []
    for n in range(num_cols):
        headers.append(mod.headerData(n, Qt.Horizontal))
    writer.writerow(headers)
    for i in range(num_rows):
        errors = []
        for j in range(num_cols):
            index = mod.index(i, j)
            errors.append(mod.data(index))
        writer.writerow(errors)


export_errors(tbl, out_file)
out_file.close()
2
  • thank you very much! do you know any way to add also desired field from the original layer to the topology csv?
    – Reut
    Aug 31, 2020 at 16:46
  • Hi Ben do you know how to access to instance from rulesDialog.ui ? because I can't acces to attribute check_dock.mConfigureDialog Apr 9 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.