Bug report #5223

ftools Intersection fails to gathering all shapes

Added by John Lortscher over 12 years ago. Updated over 7 years ago.

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

Description

In both 1.7.1 (which I used until yesterday) and 1.7.4, when I use vector:geoprocessing tools:intersect, known shapes are missing from the result set.

Example: Using TIGER line shapefiles (downloaded from http://www.census.gov/geo/www/tiger/tgrshp2011/tgrshp2011.html), I do the following:
1. Create a new QGIS project, and add shapefiles for Illinois Places and for Illinois Counties.
2. Select Cook County in the Counties shapefile.
3. Open the window for vector:geoprocessing tools:intersect
4. Specify Counties as the Input vector layer (do not mark "use only selected features")
5. Specify Places as the Intersect layer (mark "use only selected features").

My expectation is that the result set will contain all of the places (cities) that are partially or entirely within Cook County, IL. However, Chicago City is missing as are all of the places/cities that straddle the Illinois border. Other places may be missing as well but these are the ones that are blatently obviouis.

inter_grass_shp.zip (1.04 MB) Giovanni Manghi, 2012-03-27 06:57 AM

inter_postgis_shp.zip (639 KB) Giovanni Manghi, 2012-03-27 06:57 AM

cook_proj_shp.zip (61.3 KB) Giovanni Manghi, 2012-03-27 06:57 AM

History

#1 Updated by Giovanni Manghi over 12 years ago

  • Status changed from Open to Feedback

I'm sorry but if you select a feature in a layer and you do not mark "use only selected features" then is like using every feature in that layer.

The same way if you don't select any feature in a layer and mark "use only selected features" then is like using none of the features in than layer.

It does not make sense, I'm not surprised you are not getting the expected results. Please leave feedback.

#2 Updated by John Lortscher over 12 years ago

Hi Giovanni,

I apologize ... I accidentally switched "Counties" and "Places" in lines 4 and 5 of my description (corrected below). Basically I am trying to use Cook County (from the county file) to select all Places (cities) that are either entirely or partially within Cook County. It looks like Intersect is selecting only those shapes that are entirely within Cook County. If a "place" (city) straddles Cook County (partially in Cook County and partially outside of Cook County) it ignores those shapes. Is that the expected behavior? If so, it there a way in ftools do what I am trying to accomplish (select all cities that are either entirely within or partially within Cook County)? If not ftools, can you recommend another plug-in that would get the job done?

I apologize again for my foul-up of the original description. Thank you for all your help.

John

In both 1.7.1 (which I used until yesterday) and 1.7.4, when I use vector:geoprocessing tools:intersect, known shapes are missing from the result set.

Example: Using TIGER line shapefiles (downloaded from http://www.census.gov/geo/www/tiger/tgrshp2011/tgrshp2011.html), I do the following:
1. Create a new QGIS project, and add shapefiles for Illinois Places and for Illinois Counties.
2. Select Cook County in the Counties shapefile.
3. Open the window for vector:geoprocessing tools:intersect
4. Specify Counties Places as the Input vector layer (do not mark "use only selected features")
5. Specify Places Counties as the Intersect layer (mark "use only selected features").

My expectation is that the result set will contain all of the places (cities) that are partially or entirely within Cook County, IL. However, Chicago City is missing as are all of the places/cities that straddle the Illinois border. Other places may be missing as well but these are the ones that are blatently obvious.

#3 Updated by Giovanni Manghi over 12 years ago

Hi John

John Lortscher wrote:

Hi Giovanni,

I apologize ...

It is ok, now I also understand better the issue.

I see the "strange" result, so I made a test and done the same operation with PostGIS

create table inter1_postgis as select
ST_Intersection(v.the_geom, m.the_geom) as the_geom
FROM place m, cook v
where ST_Intersects(v.the_geom, m.the_geom);

and the result is the same. This is not surprising as both QGIS and PostGIS are using the GEOS library to do such operations. I also made the same tests after saving the input vectors in a projected CRS (EPSG:3528 - NAD83 / Illinois East)

I then used something different, GRASS. With the v.overlay.and tool the result is the expected. GRASS is a completely different tool, as is a fully topological GIS and is known to handle "better" problematic vectors.

I would say here that the problem is NOT in QGIS, but in GEOS. I would suggest then to close this ticket as invalid and file a new ticket in the GEOS bug tracker.

#4 Updated by John Lortscher over 12 years ago

Thank you Giovanni. I just created a ticket http://trac.osgeo.org/geos/ticket/521 on the GEO web site. I hope I put it in the right place?

One quick question before I close out the ticket (or should I move it elsewhere?). I have never used GRASS but it looks like I should read up on it in the QGIS manual. Is the main idea that I open a QGIS project, add my two vector layers (the county and city shape files) and then use the GRASS tool? You mentioned v.overlay; I am not sure what that is ... perhaps it will be clear when I read about GRASS?

Thanks again for your help.

#5 Updated by Giovanni Manghi over 12 years ago

  • Status changed from Feedback to Closed
  • Resolution set to upstream

One quick question before I close out the ticket (or should I move it elsewhere?). I have never used GRASS but it looks like I should read up on it in the QGIS manual. Is the main idea that I open a QGIS project, add my two vector layers (the county and city shape files) and then use the GRASS tool? You mentioned v.overlay; I am not sure what that is ... perhaps it will be clear when I read about GRASS?

GRASS is powerful GIS program, it has its own GUI and works also completely from the command line. It can be used inside the QGIS environment thanks to a "GRASS toolbox". It has a more advanced data model when compared to the vast majority of other GIS software, for this reason the data usually needs to be imported into GRASS (data model) before start working on it. The QGIS manual is a good start.

#6 Updated by Giovanni Manghi over 12 years ago

  • Target version changed from 35 to Version 1.8.0

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