# Tag Info

21

The following quoted text came from a deleted blog post at infogeoblog.wordpress.com which was called Geo-Processing in QGIS. Given two input shapes: Clip creates a new shape based on the area of the input layer that is overlapped by the clipping layer. It is similar to the intersection but differs in that the attributes of the chosen layer only are copied ...

11

Here are a few new tricks, using: EXCEPT to remove geometries from either table that are the same, so we can focus only on geometries that are unique to each table (A_only and B_only). ST_Snap to get exact noding for overlay operators. Use the ST_SymDifference overlay operator to find the symmetric difference between the two geometry sets to show the ...

8

Try converting your rasters to numpy arrays and then check to see if they have the same shape and elements with array_equal. If they are the same, the result should be True: ArcGIS: import arcpy, numpy raster1 = r'C:\path\to\raster.tif' raster2 = r'C:\path\to\raster.tif' r1 = arcpy.RasterToNumPyArray(raster1) r2 = arcpy.RasterToNumPyArray(raster2) d = ...

6

I think it is a little bit tricky, because of the different node sets of your both polygons (green polygon A, red different segments of polyon B). Comparing the segments of both polygons give a clue which segments of polygon B will be modified. Nodes polygon A Nodes of the "different" segments polygon B Unfortunally this show only the difference in ...

6

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() feats_list = [] for feat in layer.getFeatures(): feats_list.append(feat) print feats_list # 'feats_list' is something like: # [<qgis._core.QgsFeature ...

5

Do you know shpdiff which depends on shapelib? It's not Python but works similar to diff. You can get it from here: http://uwmike.com/maps/shapefiles/shpdiff.c Some years ago I wrote a blog post about it.

5

The problem was that the blue polygon was in another projection, and QGIS was projecting it on-the-fly. It seems QGIS geoprocessing tools perform operations in the defined projection rather than on-the-fly. Difference is the right geoprocessing tool, but both the input and the difference layer had to be defined in the same projection.

5

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 it should be more robust in handling polygons which have very small overlaps or coincident linework. It also avoids the need to drop polygon intersection ...

4

You could have a try with gdalcompare.py script http://www.gdal.org/gdalcompare.html. The source code of the script is at http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/scripts/gdalcompare.py and because it is a python script it should be easy to remove the unnecessary tests and add new ones to suit your current needs. The script seems to do pixel ...

4

Buffer the lines. Use Difference to subtract the buffer polygon from the original polygon (p0).

4

Right...it seems that there might be an issue with QGIS 2.12.0 (and QGIS 2.10.1) not processing your shapefiles correctly. I ran the clip tool in QGIS 2.8.2 and it seems to have worked (atleast for the area you have highlighted in your question): The clipped layer using QGIS 2.10.1 and 2.12.0 (shown in red): The clipped layer using QGIS 2.8.2 (shown in ...

4

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 -> QGIS geoalgorithms -> Vector general tools -> Delete duplicate geometries. Here is an example: I have an overlapping circles that when you use an ...

4

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 earlier than the current time. The field will be 0 when the license date is later than now. If your license dates are not precise to the minute, replace the minute() ...

4

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 ms_erase function in rmapshaper. # Let's try an example using publicly available Census vector layers through tigris if(!require(dplyr)){install.packages("...

4

Managed it with this code, with explanation: fields = difflayer.fields() features_A = layer_A.selectedFeatures() features_B = layer_B.getFeatures() outgoingFeatureList = [] for f in features_A: compFeature = QgsGeometry() localFeature = QgsGeometry() outgoingFeature = QgsFeature() localFeature = f.geometry(...

4

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 finally keep either the entire original shape or compute the difference SELECT ST_Multi(COALESCE( ST_Difference(a.geom, blade.geom), a.geom )...

3

Your logic seems sound, but you have some surplus text in your query which throws an error: "::geometry(linestring, SRID)" is not required. Also note that ST_ExteriorRing() does NOT work on multi-polygons, only polygons (null will be returned from multipolys, which may explain your lack of results). Also if you are using more than one polygon in each table, ...

3

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.

3

I don't work with QGIS, but I have had similar problems with ArcMap. Something simple I tend to forget...Make sure you have no attributes selected when running the tool. I added your data...everything looks fine

3

If you run a tool where the results are not what you expected, a good test is to use the Check Geometry Validity from Vector > Geometry Tools > Check Geometry Validity. I ran this for your Gas Flares shapefile and it returned a couple of intersection errors: To resolve this, you can use v.clean from the Processing Toolbox, select the cleaning tool snap and ...

3

You can speed up the manual clean up process a bit by creating a virtual field on your final layer and populating it with the area of each feature (\$area in field calculator). Then sort the attribute table by this field. You will probable find lots of records at the top with zero or close to zero areas, and these can be deleted quickly from within the ...

3

You could try using Symetrical Difference as this, for me atleast, sometimes removes unwanted slivers if I receive them from the Difference tool. If not then you could try from QGIS: Eliminate Sliver Polygons (Vector > Geoprocessing Tools > Eliminate Sliver Polygons) Or from GRASS: v.clean (This is used to repair topology errors. Select the rmdangle tool ...

3

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 \ " Putting an extra seg_buff at the end makes the query work. This extra word is needed because ogr2ogr only automatically generates SQL table names for files ...

3

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 and if the method is suitable enough for the analysis purpose.

3

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. I do not know how to show the difference of empty and non-empty geometries with QGIS. At least the attribute view does not do it. I saved the result as ...

3

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', 'my_polygons', 'ogr') diff = processing.runalg("qgis:difference", my_lines, my_polygons, False, None) result = processing.getObject(diff['OUTPUT']) _writer = ...

3

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 girls via a t-test is based on a model of boys and girls having a normally distributed height with either equal or different variances and the test is whether ...

3

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 within a, b.difference(a) is an empty geometry a.contains(b) True b.within(a) True Demonstration with the with the Java Topology Suite (JTS) and a ...

3

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 features from your point layer that are disjoint (not in or touching) the polygons of your buffer layer. Once you have a selection you can either save it using ...

3

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 'polygonsB' that have the same (idA) value in the field 'idB'. It is possible in a simple way as long as there is a single feature in polygonsB for each value of the ...

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