The way you are doing it will work but it will take too much time, since postgis is trying to create the geometry of the intersection of every "blockgroup vs town" combination, even when they don't even touch.
Add another condition check to your WHERE clause to check if the two geometries intercept, and put it before the existing one:
You can do it in QGIS using symbol transparency, feature blending mode and symbol color.
Notice the difference between Layer Transparency and blending mode(that will be applied to all features) and the symbol transparency and feature blending mode that will stack with other features in the same layer.
All seetings are available in Layers Properties > Style....
To remove duplicates:
You can use the Delete duplicate geometries tool by accessing it via the Processing Toolbox:
Another option is to use the v.clean tool from GRASS and select the rmdupl option:
To remove overlaps:
You can use the Dissolve tool, provided there are common attributes between the original polygon and the overlapping polygon:
As always, ...
A self-join allows you to operate on the relationship between pairs of two features. But I don't think you're interested in pairs: for each feature, you want to operate on the relationship between that feature and all other features in your dataset. You can accomplish this with a subquery expression:
CREATE TABLE parcels_trimmed AS
SELECT id, ...
In the situation where you only need to know whether a table contains any overlapping polygons, and you're not concerned with the size or abundance of overlaps, I recommend a query of the following form:
FROM my_table a
INNER JOIN my_table b ON
(a.geom && b.geom AND ST_Relate(a.geom, b.geom, '2********'))
WHERE a.ctid != b.ctid
Enable Topology Checker Plugin in Plugin Manager. Add your polygonal layer in Topology Rule Settings window, select "must not overlap" rule and add them. To see overlap errors click on Validate button.
Adding to Alexandre's very useful answer, if some of your census units may span three of your towns (and therefore you can't guarantee more than 50% falls in any town) you can do this:
select distinct on (b.id)
(st_area(st_intersection(b.wkb_geometry, t.wkb_geometry))/st_area(b.wkb_geometry)) as proportion
from blockgroups b, towns t
import geopandas as gpd
g1 = gpd.GeoDataFrame.from_file("poly_intersect.shp")
1) You can use the itertools module
a) If you want to merge the intersections of the overlapping polygons
geoms = g1['geometry'].tolist()
intersection_iter = gpd.GeoDataFrame(gpd.GeoSeries([poly.intersection(poly) for poly ...
Try renderers: "Point displacement" or "Point Cluster" from symbology menu. (QGIS 3.x required for point cluster.)
As point displacement they can look like this for example:
And as point cluster like this for example:
Play around with the settings to fit your needs. You can combine these with graduated, categorized or rule based ...
I recommend that you try using the Intersect (Analysis) tool with one input.
According to How Intersect works (with my bolding):
Intersect can run with a single input. In this case, instead of
discovering intersections between the features from the different
feature classes or layers, it will discover the intersections between
features within the ...
This is a really nice application for a PostgreSQL trigger. To set up a trigger in PostgreSQL, you do two things:
Create a user-defined function that is run whenever a trigger is called (can be a row insert, update, or delete)
Use a CREATE TRIGGER statement to bind that function to a particular table for a particular operation (in this case, INSERT).
There is a possibility using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...
Let's assume we have three features in 'vegetation' (green) and four in 'treatment' (red) accordingly, see image below.
With the following Query, it is possible to add a field to the attribute layer of the vegetation layer to indicate if any ...
areas = 
for line_feature in line_layer.getFeatures():
cands = area_layer.getFeatures(QgsFeatureRequest().setFilterRect(line_feature.geometry().boundingBox()))
for area_feature in cands:
Add a new field to both layers to hold the original areas and call it Area
Calculate the areas for all the polygons in each layer and put into the Area field
Execute a union of layer 1 and layer 2 - make Layer 1 target layer and include FIDs
Add two new fields to the union result - AreaCalc and PC_Overlap
Calculate the areas for the resulting union layer ...
One way of doing this is cloning the layer, using definition queries and labelling them separately, using upper-left only label position for the first layer and lower-left for second.
Add THEFIELD type integer to layer and populate it using expression below:
It is very complicated task known as bin packing problem.
The script below produces one of countless sub-optimal solutions. Algorithm:
places fish net over rotated POLYGON to find out rotation angle in range (0,175,5) that result in maximum count of complete rectangles
breaks if no such rectangles found, otherwise
un-rotate every good rectangle and append ...
In QGIS I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...
Let's assume we have two polygon layers 'Layer_A' (brown) and 'Layer_B' (green) respectively, see image below.
With the following query, it is possible to achieve the result, i.e. to perform a spatial join and put the result comma separated in ...
Fortunately, with the prio dependency, this is easier to solve than a purely recursive difference aggregation.
I'd prefer the LATERAL statement (here in full verbose mode), both for clarity of the statement and performance
)) AS geom
FROM table1 AS a
CROSS JOIN ...
First make sure your Buildings have a unique "id" (which does not contain a | character, you will see why below). You can add it for example via field calculator by adding a new field with the expression $id if they do not have one already.
Then run the "Polygon Self-Intersection" from SAGA Processing tools and choose this "id" ...
This can be easily accomplished using PostGIS. Preview the results using a modified version of the query below:
SELECT a.id, b.id, ST_Area(a.shape), ST_Area(b.shape)
, 100*(ST_Area(ST_Intersection(a.shape, b.shape))/LEAST(ST_Area(a.shape), ST_Area(b.shape)))::numeric(5,2)
, ST_Union(a.shape, b.shape) as new_shape
Take your model layer and in the attribute table, add a new field called area_mod for example.
Note that there are two ways to generate area:
$area is an ellipsoid based calculation using not just the area units but also factors in the projects spatial reference system (SRS) ellipsoid
area($geometry) is planimetric where is uses only the area units of the ...
True Polygon containment is a costly operation; not only does a containment check have to run intersection computations between each pair of vertices in one polygon for each pair of vertices in the other, but is it also impossible to improve by subdividing any of them.
That being said, your query is also not going to return the desired result; you are ...
I would recommend using the Count Overlapping Features (Analysis) tool.
Generates planarized overlapping features from the input features. The
count of overlapping features is written to the output features.
You can do this with 2 tools, Feature to Polygon and Spatial Join
First, run your polygons through Feature to Polygon. Delete any of the attributes you don't need from the output (I still got them even when I turned preserve attributes off):
Then, run Spatial Join:
The target features are the output of Feature to Polygon
The join features are your ...
QGIS Processing Toolbox has a SAGA Polygon self-intersection tool (under SAGA | Vector polygon tools).
It works much like QIGS Union Tool, while this tool retains only one feature per the overlapped area.
Open the attribute table of generated Intersection layer and select Delete all features whose fid (or id) is 0.
Since QGIS 3.8, it's now included in QGIS core, without plugin or coding.
In the Processing Toolbox, search for Overlap and open the Overlap analysis:
If your Ecuador layer is several polygons, I would start off by running the "Dissolve" tool. This will create 1 merged feature.
Following that, I would run the "Multiparts to Singleparts" tool on the dissolved layer. This is because you have some disconnected polygons. You should now get like 5-10 features (based on your screenshot), but ...
You can dissolve without a dissolve field but Im not sure if that is what you want.
I suspect it is:
Multipart to singleparts
Field calculate @row_number
Intersect output with your original data. Now you have your input data with a group attribute: