41 votes

Filter by bounding box in GeoPandas

You can use the cx method on a geodataframe to select rows within a bounding box. For your example frames: xmin, ymin, xmax, ymax = df_sussex.total_bounds sac_sussex = df_sac.cx[xmin:xmax, ymin:ymax] ...
user avatar
  • 812
29 votes
Accepted

Refering to another layer with Field Calculator in QGIS

For QGIS versions QGIS 3.16 and higher Since QGIS 3.16 the functionality of the "refFunctions plugin" was emended into core. The current corresponding function is the overlay_within(). For ...
user avatar
  • 1,876
26 votes

Removing overlapping/duplicate polygons in the same layer using QGIS

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: ...
user avatar
  • 72.5k
24 votes
Accepted

Check whether table has overlapping polygons, in PostGIS?

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 ...
user avatar
  • 12.4k
23 votes

Refering to another layer with Field Calculator in QGIS

Out of the box, field calculator does not support spatial joins across feature layers. But, if you have a look at NathanW's post on the function editor for qgis expressions you will be able to make ...
user avatar
  • 3,711
22 votes
Accepted

Using ST_Difference to remove overlapping features?

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 ...
user avatar
  • 12.4k
21 votes

Displaying overlapping points in QGIS

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 ...
user avatar
  • 26.2k
19 votes
Accepted

Identifying overlapping polygons in single layer using QGIS?

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....
user avatar
  • 3,491
19 votes

Refering to another layer with Field Calculator in QGIS

It can be done in Field Calculator with function aggregate(). In point layer create new field with field calculator expression like this: aggregate( layer:= 'polygon_layer_name', aggregate:='...
user avatar
  • 6,487
19 votes
Accepted

Merging overlapping features using Geopandas?

The GeoDataFrame import geopandas as gpd g1 = gpd.GeoDataFrame.from_file("poly_intersect.shp") g1.shape (4, 3) 1) You can use the itertools module a) If you want to merge the intersections of the ...
user avatar
  • 51.4k
18 votes

Calculating percent area of intersection in WHERE clause

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 ...
user avatar
  • 311
16 votes

Find overlapping polylines in same layer in ArcMap?

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 ...
user avatar
  • 63.9k
16 votes

Summing up values of overlapping polygons in QGIS

QGIS 3.2 Thanks to new Union tool in QGIS 3.2, this has become quite easy!!! What we do, is just use Union and Aggregate tools. (1) Union (Processing Toolbox | Vetor Overlay | Union) (2) We ...
user avatar
  • 29.2k
14 votes
Accepted

Removing overlaps and keeping highest priority polygon using PostGIS

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 ...
user avatar
  • 24.5k
13 votes
Accepted

Correcting the geometry of overlapping polygons in the same layer in QGIS

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 ...
user avatar
  • 26.2k
12 votes
Accepted

Select polygon features that intersect a line feature using pyqgis

areas = [] for line_feature in line_layer.getFeatures(): cands = area_layer.getFeatures(QgsFeatureRequest().setFilterRect(line_feature.geometry().boundingBox())) for area_feature in cands: ...
user avatar
  • 4,420
12 votes

Calculating percentage of overlap between two different layers using ArcMap

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 - ...
user avatar
  • 6,410
12 votes
Accepted

Getting attribute information of multiple polygon intersected by line

Try this expression: array_to_string(overlay_intersects('Layer_A', name)) (assuming the City names are stored in name field in the 'Layer A').
user avatar
  • 29.2k
11 votes

Can labels for overlapping points be combined/merged into one label?

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 ...
user avatar
  • 21.7k
11 votes
Accepted

Removing overlapping part of polygons using QGIS?

You can use the 'Check Geometries' plugin (Vector/Geometry Tools/Check Geometries) to remove overlapping areas.
user avatar
11 votes
Accepted

Filter by bounding box in GeoPandas

Issue is because you are using 'total_bounds' method. It only produces a tuple with max and min points of bounding box. Method to be used is 'envelope'; previous to build its respective 'GeoDataFrame'....
user avatar
  • 26.9k
11 votes
Accepted

Fitting known size polygons into irregular polygons using ArcGIS Desktop?

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 ...
user avatar
  • 21.7k
10 votes
Accepted

Dissolve overlapping polygons according to percent overlap using PostGIS?

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(...
user avatar
  • 1,135
10 votes

Calculating proportional area of polygon within another layer's polygon using QGIS

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 ...
user avatar
  • 9,991
10 votes
Accepted

Listing IDs of polygons within another polygon in the Attribute table

A Virtual layer would work well here: First hit 'Import' to add your layers then add the query: SELECT A.id, group_concat(b.id) FROM A LEFT JOIN B ON ST_Intersects(a.geometry, b.geometry) GROUP BY A....
user avatar
10 votes
Accepted

Looking for QGIS equivalent of ArcMap's "Selection by Location" tool with "Have their centroid in" option

There is no direct equivalent in Qgis core, but you can use the "Select Within" plugin, which should do exactly what you need (it adds an entry in the vector menu): Otherwise, you would need to ...
user avatar
  • 811
10 votes
Accepted

Best practice for counting polygons in polygons

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 ...
user avatar
  • 24.5k
10 votes
Accepted

Dissolving polygons that intersects in QGIS

You can dissolve without a dissolve field but Im not sure if that is what you want. I suspect it is: Dissolve Multipart to singleparts Field calculate @row_number Intersect output with your original ...
user avatar
  • 53.9k

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