ArMoraer / QGISMergeLines

MergeLines plugin for QGIS
9 stars 5 forks source link

Python error - Failed to merge #3

Open imcatfhdk opened 8 years ago

imcatfhdk commented 8 years ago

Hi

I get the error message mentioned below when I try to merge lines either by length or alignment. I use QGIS 2.14.0. The same error was confirmed by by a person using 2.14.3.

The error happens instantly when pressing "OK" (starting the merging).

Copied from the log panel:

Traceback (most recent call last): File "C:/Users/imc/.qgis2/python/plugins\QGISMergeLines-master\merge_lines.py", line 216, in onStart self.joinLines( inputLayer, params ) File "C:/Users/imc/.qgis2/python/plugins\QGISMergeLines-master\merge_lines.py", line 312, in joinLines deletedFeaturesID += delFeaturesID UnboundLocalError: local variable 'delFeaturesID' referenced before assignment

Screenshot error message mergelines

ArMoraer commented 8 years ago

Hi, I'll have a look at this issue in the next days.

ArMoraer commented 8 years ago

Hi again, I wasn't able to reproduce this issue on QGIS 2.14.3. Can you post the shapefile you used so I can test it?

imcatfhdk commented 8 years ago

Hi. Sorry for the late reply. The shapefile(s) are zipped and attached.

privat_jordledning.zip

ArMoraer commented 8 years ago

Sorry for the response delay. I fixed this bug in version 0.3.1, which should be available soon in QGIS plugin repo. Thanks for the feedback.

imcatfhdk commented 8 years ago

I'm looking forward to trying it out when it becomes available in the repository.

ArMoraer commented 8 years ago

The new version is available since a few days. Are you still facing the bug?

imcatfhdk commented 8 years ago

No error/bug this time! However, the lines were not joined - actually i couldn't detect any difference. Did you test the plugin on the shapefile I sent you?

ArMoraer commented 8 years ago

I just tested again (with the merge by length option, on Windows 7 and QGIS 2.14.3), and I can see a difference : there are 18084 features in the input layer, and 15276 in the output. For example, lines #5491 and 25656 (I am referring to the "mslink" attribute) were merged, as well as 9524 and 31749.

I did not perform a thorough analysis, but at first glance it looks like every line that should merge did actually merge. Unfortunately, I have no clue as to why the plugin does not work for you. How long did it run on your computer? It took around 5 minutes for me.

imcatfhdk commented 8 years ago

It took 5 min for me too every time I tried to merge the large shapefile. Unfortunately, I didn't note down the changes in number of features, I just saw that lines weren't really joined.

Now I tried to joined a smaller segment (small extract of the large .shp file)and the number of features went from 154 to 121 when it should actually have been merged to a total of 6 features. I have attached the processed shapefile. Could you see if it works for you and turns these features into 6 segments features? Maybe I am doing something wrong. MergeLines_processedExtract.zip

Btw. I use windows 7 and QGIS 2.14.3 too.

Thanks.

ArMoraer commented 8 years ago

Oh, I understand your confusion. MergeLines can not merge your segments to 6 features, because these 6 features would not be lines but multi-lines (which is not the intended goal).

For example, if you have 3 segments in a "Y" shape, MergeLines will only merge 2 of the 3 segments. This is because the initial objective of MergeLines was to simplify river networks without merging tributary rivers.

I might be able to add a "create multi-lines" option in a next version, which will address your need. It is difficult to estimate the complexity of this feature, so I don't know when (or even if) I'll do it.

imcatfhdk commented 8 years ago

I see. Thanks for clarifying. That feature would be nice indeed.