Bug report #8625

singlepart to multipart broken in QGIS 2.0/master

Added by Giovanni Manghi almost 11 years ago. Updated about 7 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Processing/QGIS
Affected QGIS version:master Regression?:
Operating System: Easy fix?:
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:17359

Description

tested on both Linux and Windows

An error has occured while executing Python code:

Traceback (most recent call last):
  File "C:\\OSGeo4W\\apps\\qgis-dev\\python\\plugins\\fTools\\tools\\doGeometry.py", line 324, in run
    success = self.single_to_multi()
  File "C:\\OSGeo4W\\apps\\qgis-dev\\python\\plugins\\fTools\\tools\\doGeometry.py", line 384, in single_to_multi
    if idVar.strip() == i.strip() or merge_all:
AttributeError: 'QPyNullVariant' object has no attribute 'strip'

Python version:
2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]

QGIS version:
2.1.0-Master Master, 773e0d4

Python path: ['C:/OSGeo4W/apps/qgis-dev/./python/plugins\\\\sextante', 'C:/OSGeo4W/apps/qgis-dev/./python/plugins\\\\processing', 'C:/OSGeo4W/apps/qgis-dev/./python', u'C:\\\\Users\\\\giovanni/.qgis2/python', u'C:\\\\Users\\\\giovanni/.qgis2/python/plugins', 'C:/OSGeo4W/apps/qgis-dev/./python/plugins', 'C:\\\\Python27', 'C:\\\\mapnik-v2.2.0\\\\python\\\\2.7\\\\site-packages', 'C:\\\\OSGeo4W\\\\bin', 'C:\\\\OSGeo4W\\\\bin\\\\python27.zip', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\DLLs', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\plat-win', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\lib-tk', 'C:\\\\OSGeo4W\\\\apps\\\\Python27', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\PIL', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\win32\\\\lib', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\Pythonwin', 'C:\\\\OSGeo4W\\\\apps\\\\Python27\\\\lib\\\\site-packages\\\\wx-2.8-msw-unicode', 'C:\\\\OSGeo4W\\\\apps\\\\qgis-dev\\\\python\\\\plugins\\\\fTools\\\\tools']

sample_data_ftools.zip (80.5 KB) Salvatore Larosa, 2014-01-07 04:36 AM

Associated revisions

Revision e4f410b5
Added by Matthias Kuhn over 10 years ago

[ftools] S'part to M'part with non-string columns and NULL values
Fix #8625

History

#1 Updated by Andrey Isakov over 10 years ago

QGIS 2.0.1
Same error.
Vector -> Geometry Tools -> Singleparts to multipart

An error has occured while executing Python code:

Traceback (most recent call last):
  File "/usr/share/qgis/python/plugins/fTools/tools/doGeometry.py", line 325, in run
    success = self.single_to_multi()
  File "/usr/share/qgis/python/plugins/fTools/tools/doGeometry.py", line 385, in single_to_multi
    if idVar.strip() == i.strip() or merge_all:
AttributeError: 'float' object has no attribute 'strip'

Python version:
2.7.5+ (default, Sep 17 2013, 15:33:59) 
[GCC 4.8.1]

QGIS version:
2.0.1-Dufour Dufour, exported

Python path: ['/usr/share/qgis/python/plugins/processing', '/usr/share/qgis/python', '/home/andrey/.qgis2/python', '/home/andrey/.qgis2/python/plugins', '/usr/share/qgis/python/plugins', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/home/andrey/.qgis2/python/plugins/mmqgis/forms', '/usr/share/qgis/python/plugins/fTools/tools'] 

#2 Updated by Salvatore Larosa over 10 years ago

This seems to happen when the layer has NULL attribute values, I had proposed a patch which
has not been applied because this commit cba57fa by Matthias solved the issue with NULL values reported in the same PR, but I am still getting a QPyNullVariant error here.

Can anyone test the tool with the attached sample data?

#3 Updated by Giovanni Manghi over 10 years ago

Salvatore Larosa wrote:

but I am still getting a QPyNullVariant error here.

confirmed

An error has occured while executing Python code:

Traceback (most recent call last):
  File "/usr/share/qgis/python/plugins/fTools/tools/doGeometry.py", line 326, in run
    success = self.single_to_multi()
  File "/usr/share/qgis/python/plugins/fTools/tools/doGeometry.py", line 386, in single_to_multi
    if idVar.strip() == i.strip() or merge_all:
AttributeError: 'QPyNullVariant' object has no attribute 'strip'

#4 Updated by Matthias Kuhn over 10 years ago

Can confirm.

Some comments:

  • Just to be sure: What is the result expected to be? Should NULL values be grouped? From a database perspective it seems like yes, but it is an edge-case
  • What about the option of removing the .strip() altogether? From a database perspective this would not be used (" a " is distinct from "a") but I can perfectly see that it may help new users to cover their data inconsistencies. What about making it an option, checked by default?
  • Your patch will lead to conflicts, when the user actually has the string u"NULL" as a value in his attributes. For my part, I'd like to get away from this substitute strings as good as possible.

#5 Updated by Giovanni Manghi over 10 years ago

  • Just to be sure: What is the result expected to be? Should NULL values be grouped? From a database perspective it seems like yes, but it is an edge-case

from a user point of view I would say "yes", group them. But if it is hard then a warning message (and ask to fill properly the null records) would be enough.

#6 Updated by Andrey Isakov over 10 years ago

Matthias Kuhn wrote:

  • Just to be sure: What is the result expected to be? Should NULL values be grouped? From a database perspective it seems like yes, but it is an edge-case

In some cases YES, in other — NO. So, I think we need an additional check-box for NULL values.

#7 Updated by Matthias Kuhn over 10 years ago

  • Status changed from Open to Closed

#8 Updated by Giovanni Manghi about 7 years ago

The "ftools" category is being removed from the tracker, changing the category of this ticket to "Processing/QGIS" to not leave the category orphaned.

Also available in: Atom PDF