Skip to main content
10 votes
Accepted

Difference function in QGIS is extremly slow

Having few (or many), very large features, especially multipart geometries, make processing slow. Try: Multipart to singleparts Subdivide Spatial index On the input layers, then try Difference again
Bera's user avatar
  • 74.3k
8 votes
Accepted

Getting the 'composite' of two polygon layers

One way to do this is to create a polygonal coverage from the linework of the inputs, and then spatially join this back to recover the parent attributes. The advantage of using this technique is that ...
dr_jts's user avatar
  • 5,133
7 votes
Accepted

Using PostGIS to find the overall difference between two (large) polygon datasets

Expanding on this answer, we can build a query that will process each geometry of table 1, then, for each of them (via the lateral join), union all intersecting geometries from the 2nd layer and ...
JGH's user avatar
  • 42.3k
6 votes
Accepted

How to use the method makeDifference in the console?

If you need to perform a simple difference operation between to features, the difference() method should be enough. Assuming to start from two features stored in a list: layer = iface.activeLayer() ...
mgri's user avatar
  • 16.2k
6 votes
Accepted

ST_difference resulting in multiple overlapping polygons and no difference

You have done a full cross table join, so you have intersected every road against every land cover polygon in turn, so you have (N-1) polygons that don't intersect for ever polygon that does (where N ...
Ian Turton's user avatar
  • 82k
5 votes
Accepted

Function in R to get difference between two sets of polygons comparable in speed to QGIS

The rmapshaper package offers a faster function for "erasing" or finding the difference between two polygon layers in R. Below is a comparison of the st_erase approach with sf and the ...
Marcos's user avatar
  • 356
5 votes

Doing difference between two layers in PyQGIS?

Managed it with this code, with explanation: fields = difflayer.fields() features_A = layer_A.selectedFeatures() features_B = layer_B.getFeatures() outgoingFeatureList = [] for f ...
user25730's user avatar
  • 894
5 votes

GEOS geoprocessing error when using difference tool in QGIS

Not a very useful error message is it! Firstly, lets see if we can do something about that. You can check the QGIS log panel. (Right click on tool bar > Log Messages Panel) This may give you more ...
nr_aus's user avatar
  • 3,566
5 votes
Accepted

Difference of two polyline layers in QGIS

where layer B basically has the same geometry in exactly the same positions The problem is that it is not true. LineString geometries are defined by their vertices. But since this vector data model (...
Gabriel De Luca's user avatar
4 votes

Creating rings from existing polygons using QGIS?

To clean overlapping circles, I will use v.clean from Processing toolbox in QGIS -> GRASS GIS -> Vector -> v.clean, then I will use Delete duplicate geometries from Processing toolbox in QGIS ...
ahmadhanb's user avatar
  • 41k
4 votes

Can ogr2ogr "reverse clip" (or "clip out" or "erase" or "difference") one shapefile from another?

Try this, ogr2ogr -f "ESRI Shapefile" out.shp road.shp \ -dialect sqlite -sql "\ select ST_Diffrence(road.geometry, seg_buff.geometry) \ from road, 'seg_buff.shp'.seg_buff seg_buff \ " ...
Shadab's user avatar
  • 41
4 votes

Difference Between Polygon Layers

Ok, it seems that the layer difference tool in QGIS keeps all the rows and computes a new geometry for all of them. As a result there is a new layer with 15 rows and 12 of them has an empty geometry. ...
user30184's user avatar
  • 66.9k
4 votes
Accepted

shapely.difference() possible bug or wierd behavior

You must understand the differencespatial function: the difference of A and B returns the portion of the first geometry (A) that isn't intersected by the second geometry (B). In your example, as b is ...
gene's user avatar
  • 55.1k
4 votes
Accepted

Style features based on difference between current date and date in attribute table

Using the Field Calculator, create an integer-type Virtual Field with an expression like this: minute( age( now() , "licensedate" )) > 0 This field will read 1 (true) if the license date is ...
csk's user avatar
  • 24.9k
4 votes
Accepted

Vector difference between two polygon layers by attribute

Assuming that you have a polygon layer named 'polygonsA', with a field named 'idA'; and you want to make the difference between any feature of that layer and the feature of the polygon layer '...
Gabriel De Luca's user avatar
3 votes

Map statistical significance in the difference of two raster maps

You can only make statements about statistically significant difference if you have a statistical model for your measurements. So the usual test of whether 10 year old boys are taller than 10 year old ...
Spacedman's user avatar
  • 64.7k
3 votes
Accepted

Deleting sliver polygons after difference operation in QGIS

If ST_Difference doesn't get you where you want try a ratio of area and perimeter by making new attribute fields and calculating. You will have to make a judgement call where to set the ratio filter ...
user92055's user avatar
  • 409
3 votes
Accepted

Difference between lines and polygons using geopandas

Meanwhile here is the solution I wrote using pyqgis, it works for me : my_lines = QgsVectorLayer('/path/to/my_lines.shp', 'my_lines', 'ogr') my_polygons = QgsVectorLayer('/path/to/my_polygons.shp', '...
Hicham Zouarhi's user avatar
3 votes
Accepted

Whats wrong with the difference tool QGIS 2.14.1?

I get the same result in ArcGIS and QGIS, but in QGIS I used the difference tool from SAGA vector polygon tools. Here the result.
Manuel Alejandro's user avatar
3 votes
Accepted

Using "Difference" geoprocessing tool on Big Data taking a very long time

I think you are doing too much work and have an unoptimised data source. First what you actually want to use is a spatial select (Select by Location in the Vector research tools menu. Simply select ...
Ian Turton's user avatar
  • 82k
3 votes

PyQgis difference iteration

When you find a matching ID between two features, you can select them and then make use of the QgsProcessingFeatureSourceDefinition class which allows you to use selected features inside your ...
Joseph's user avatar
  • 75.9k
3 votes

PyQgis difference iteration

You can achieve this using a virtual layer. You would join the two layers on their objectid and compute the difference between the matching geometries. go to the menu Layer > Add Layer > Add/...
JGH's user avatar
  • 42.3k
3 votes
Accepted

Calculate difference of two LineString

Use buffer to implement something like tolerance for this probelm Given two lines blue and green code in PostGIS with shared as ( select st_intersection(st_buffer(blue.geometry, 0.05), st_buffer(...
eth4io's user avatar
  • 376
3 votes
Accepted

QGIS difference operation with XYZ tiles

The Difference operation is an operation that only works with vector layers (as you can see from the fact that it's located in the vector menu). You can't process any raster with that. The ...
Babel's user avatar
  • 72.4k
3 votes
Accepted

Difference tool for rasters

There is a processing tool called Raster Difference. You can find it under Processing-Toolbox-Saga-RasterCalculus.
Gakovî's user avatar
  • 445
3 votes
Accepted

QGIS v/s MapInfo - Differences in Distance Measurements

QGIS does not always compute ellipsoidal areas. User can select planimetric areas with the project settings.
user30184's user avatar
  • 66.9k
3 votes
Accepted

"Difference failed" error when using difference tool with point layers as input and overlay in QGIS

I get the same error. How to solve the problem: Apply a (small) buffer of the same size around both point layers. Run the Difference tool on these buffers. From the resulting buffers (the difference),...
Babel's user avatar
  • 72.4k
3 votes
Accepted

QGIS 3.18 difference doesn't work with points as the input layer

The "GEOS geoprocessing error: difference failed" issue with the "Difference" processing algorithm is now fixed in the developer version QGIS 3.27.0-Master starting from the ...
Andrea Giudiceandrea's user avatar
3 votes
Accepted

Creating field with difference between areas of two layers in QGIS

Use the following expression in the Field Calculator of layer 1: $area - array_sum(overlay_contains('layer_2', "area")) Explanation: With overlay_contains(), you get all the polygons from ...
Babel's user avatar
  • 72.4k
3 votes
Accepted

How to create one raster layer from two raster layers in which priority is given to one of the raster layers' values (the smaller in extent)

The problem are the "no data" values! Try the following: Replace the "no data" values by e.g. -9999 with the tool "Fill NoData cells" from the toolbox Use the raster ...
oekoplaner's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible