Bug report #2497

ftools: difference tool (asymmetrical difference) does not work with multipolygon geometries

Added by Giovanni Manghi almost 10 years ago. Updated over 2 years ago.

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

Description

When trying to make a "difference" operation between polygon layers and both are multipolygon then the following warning is issued

Warnings:
GEOS geoprocessing error: One or more input features have invalid geometry.
Some output geometries may be missing or invalid.

and the resulting geometry is wrong (empty).

The same happens if the diffence layer is multipart and the input layer singlepart, while otherwise, or with both input/difference layers as singlepart, acceptable results are given and no GEOS error messages are thrown.

In general I would suggest to add a control and don't allow to use multipart geometries in this operation in order to avoid problems.

test_project.zip (3.6 MB) Giovanni Manghi, 2012-05-27 02:32 AM

inter2_singlepart.zip (2.98 MB) Giovanni Manghi, 2012-05-27 02:32 AM

40.png (344 KB) Giovanni Manghi, 2012-05-27 09:15 AM

image_1.png (260 KB) Salvatore Larosa, 2012-05-27 10:22 AM

image_2.png (221 KB) Salvatore Larosa, 2012-05-27 10:22 AM

butta.zip (298 KB) Giovanni Manghi, 2012-05-28 07:48 AM

History

#1 Updated by cfarmer - almost 10 years ago

Difference between multipolygon (and multiline) features works ok for me here, could you please attach a test dataset to replicate this error?

-Carson

#2 Updated by Giovanni Manghi almost 10 years ago

Hi Carson,
thanks for looking into this.

Yes I can attach the problematic data but not right now: the input vectors were obtained along a geoprocessing exercise and I need to create them again. I'll do it tomorrow.

thanks in advance

#3 Updated by Giovanni Manghi over 9 years ago

Replying to [comment:1 cfarmer]:

Difference between multipolygon (and multiline) features works ok for me here, could you please attach a test dataset to replicate this error?

-Carson

Hi Carson,

here I am again.

So you can test the following shapes:

http://mapserver.uevora.pt/~mapserver/viaria_evora_buffer_shp.zip

http://mapserver.uevora.pt/~mapserver/interdita2_shp.zip

Use the first as input layer and the second as difference layer.

The first one was obtained by buffering a line vector. The second one was obtained by unioning 3 shapes obtained by buffering (2) a line vector and a point vector plus a polygon vector. This line, point and polygon were obtained initially by clipping bigger vectors.

Only ftools was used for this exercise.

#4 Updated by Alexander Bruy over 8 years ago

Samples are not available anymore

#5 Updated by Giovanni Manghi over 8 years ago

I'll give new links asap, not before testing again the problem.

#6 Updated by Giovanni Manghi almost 8 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#7 Updated by Paolo Cavallini over 7 years ago

  • Affected QGIS version set to master
  • Target version changed from Version 1.7.4 to Version 1.8.0
  • Crashes QGIS or corrupts data set to No

#8 Updated by Salvatore Larosa over 7 years ago

  • Status changed from Open to Feedback
  • Pull Request or Patch supplied set to No

Hi Giovanni,
is it replicable still?

#9 Updated by Giovanni Manghi over 7 years ago

  • Priority changed from Low to High
  • Status info deleted (0)
  • Operating System deleted (All)
  • Assignee changed from cfarmer - to Alexander Bruy
  • Status changed from Feedback to Open
  • File inter2_singlepart.zip added
  • File test_project.zip added

Salvatore Larosa wrote:

Hi Giovanni,
is it replicable still?

Hi Salvatore,

yes this is still an issue here. I recreated the original sample data and attached here again.

Basically this time I don't get any error message or warning from the console, but the asymmetrical difference between between "buffer_viaria" and "inter2" does not seems to come to and end (the progress bar stay 100% for hours and something is written. Using the symmetrical difference the progress bar stay at 2%). I tested also to create a singlepart version of the "inter2" layer, but the results are similar... and I found also that the result of the multipart to singlepart using "inter2" as input does not return a single part layer at all.

#10 Updated by Jürgen Fischer over 7 years ago

Which GEOS version are you using?

#11 Updated by Salvatore Larosa over 7 years ago

Giovanni, I can confirm the issue only for symdifference tool.
Multi to Single part tool works fine!

How do you generate the inter2 shapefile?
It seems the result of several merge and union operation! is it so?

@Jürgen: GEOS 3.3.3

#12 Updated by Giovanni Manghi over 7 years ago

Jürgen Fischer wrote:

Which GEOS version are you using?

I'm using qgis-master installed from the nightly build repo, the one that uses the ubuntugis packages. I'm on precise 64bit but actually GEOS says it's 3.2.2 Oneiric.

#13 Updated by Giovanni Manghi over 7 years ago

Salvatore Larosa wrote:

Giovanni, I can confirm the issue only for symdifference tool.
Multi to Single part tool works fine!

see attached screenshot, seems multipart to me, but I may be wrong.

How do you generate the inter2 shapefile?
It seems the result of several merge and union operation! is it so?

it was obtained by unioning (in two steps)* 3 buffers layers -> a pretty common operation I would say

*) the lack of possibility to do some geoprocessing operations using more than 2 inputs is sometimes frustrating. Would be very useful for real life work.

#14 Updated by Salvatore Larosa over 7 years ago

Giovanni Manghi wrote:

see attached screenshot, seems multipart to me, but I may be wrong.

To me those are 2 Polygons! geometry().wkbType() returns 3 for both! (see attached image 1)
I used your attached sample iter2_single.
Save selection as... and check out! (see attached image 2)

it was obtained by unioning (in two steps)* 3 buffers layers -> a pretty common operation I would say

*) the lack of possibility to do some geoprocessing operations using more than 2 inputs is sometimes frustrating. Would be very useful for real life work.

your operations have created geometry crossed, most likely!

#15 Updated by Giovanni Manghi over 7 years ago

To me those are 2 Polygons! geometry().wkbType() returns 3 for both! (see attached image 1)

ok forget about it, sorry for the noise

your operations have created geometry crossed, most likely!

I don't know exactly what do you mean, but anyway the layer was obtained by unioning 2 polygon layers obtained as buffers from 3 input layers... so nothing fancy. If this ayer is somehow wrong then QGIS should at least warn the user and propose a solution, or better should be able to handle this case, as at the end of the day this is what most of the users do.

cheers!

#16 Updated by Salvatore Larosa over 7 years ago

Sorry, fear of being badly explained!!

I try again with an example (layer section):

                                     selected             selected
                     | LAYER 1 ______    ↓     ________      ↓      ___________ |
*LAYER inter2_single-|                                                          |
                     | LAYER 2 ________________________________________________ |

*derived from union/merge/buffer operations

so, LAYER 2 looks as a Multipart instead it is not!

I agree that we need to find a solution to the problem!

Anyway, before the last change in fTools plugin, many tools created duplicated geometries (especially union tool) so you should try again in order to figure out if the problem is in union/merge/buffer operation!

If you can share the inuput data I'll try it!

#17 Updated by Giovanni Manghi over 7 years ago

If you can share the inuput data I'll try it!

thanks for the effort Salvatore!

attached a small project. You will find 4 shapes in two different groups (3+1). Buffer the shapes (say 1000m) and then union the results of the group with 3 shapes and then try to do the difference between the result of the union and the remaining buffer layer.

#18 Updated by Salvatore Larosa over 7 years ago

Done!
everything went well!

I have not encountered major problems, each tool has worked well enough.
Maybe if you can control the end result if it goes well!

here the project: http://lrssvt.ns0.it/butta_2.zip

#19 Updated by Giovanni Manghi over 7 years ago

  • Resolution set to worksforme
  • Status changed from Open to Closed

Salvatore Larosa wrote:

Done!
everything went well!

I have not encountered major problems, each tool has worked well enough.
Maybe if you can control the end result if it goes well!

here the project: http://lrssvt.ns0.it/butta_2.zip

pretty strange... it now works :)

I'm bored of this ticket so I'll close it and hope not to need to reopen it again anytime soon! ;)

#20 Updated by Giovanni Manghi over 2 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