Skip to main content
17 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 ...
Kazuhito's user avatar
  • 31k
17 votes
Accepted

Unions of SVG Point Markers In QGIS?

Since your symbol are quiet simple, you can use a simple marker and set the blending mode to lighten
JGH's user avatar
  • 42.5k
15 votes
Accepted

Shapely polygon union results in strange artifacts of tiny, non-overlapping areas

This is typically a result of the the borders not fitting perfectly one next to another (and this is very easy to get with floating point coordinates). As an example, I use the world dataset ...
joris's user avatar
  • 3,933
12 votes
Accepted

Merging layers and excluding some of the products in QGIS

You can use the "Snap geometries to layer" tool by specifying the tolerance distance before "Union". In the example, the green layer is snapped to the red layer so that the gap ...
Kadir Şahbaz's user avatar
11 votes
Accepted

Split a line when it crosses a polygon in R

Here is an answer that applies sf package functions to the reproducible data kindly provided by rcs. library(sf) A <- st_as_sfc("LINESTRING(458.1 768.23, 455.3 413.29, 522.3 325.77, 664.8 282.01, ...
Josh O'Brien's user avatar
11 votes
Accepted

Only union/dissolve intersecting or adjacent features to speed up query

I would look into using ST_ClusterDBSCAN. I have had tremendous success using this function to solve many cluster like geometric problems. WITH clusters AS(select st_clusterdbscan(geom, 0, 2) over()...
ziggy's user avatar
  • 4,546
10 votes
Accepted

What does the ST_Union of the geometry column of two tables produce?

St_Union comes in two flavors, aggregate and simple. In your query you are using the simple one that is creating the union of two single geometries. What you are doing is cross joining your two ...
tumasgiu's user avatar
  • 361
9 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,218
8 votes

Finding and merging lines that touch in PostGIS?

Another option: use the PostGIS ST_LineMerge function. Here's the previous example redone with it: WITH data(geom) AS ( VALUES ('LINESTRING (0 0, 1 1)'), ('LINESTRING (2 2, 1 1)'),...
dr_jts's user avatar
  • 5,218
8 votes
Accepted

Group and union polygons that share a border in R

Here's a function that takes an sf polygons object and clusters all features within a threshold distance, then merges the features. So starting with N features you end up with M<=N features: ...
Spacedman's user avatar
  • 65.6k
8 votes
Accepted

st_write fails for object created with st_difference using R?

GPKG column names must be unique and are case insensitive. Do you have any columns where the case-folded names are the same? > any(duplicated(toupper(names(watlbahamas)))) [1] TRUE Yes. Which ...
Spacedman's user avatar
  • 65.6k
8 votes
Accepted

Creating Virtual Layer as union of multiple layers with same schema in QGIS

You can use python to print out the sql needed in the console, then copy paste it to the virtual layer. Add all layers to a group named surveyor and execute: root = QgsProject.instance().layerTreeRoot(...
Bera's user avatar
  • 76.2k
7 votes

Summing up values of overlapping polygons in QGIS

Before QGIS 3.2 This example requires MS-Excel function, along with SAGA in QGIS Processing Toolbox. (1) Start Polygon self-intersection tool in QGIS Processing Toolbox | SAGA | Vector polygon ...
Kazuhito's user avatar
  • 31k
7 votes
Accepted

QGIS Union Error: multiple overlapping polygons created where only one should exist?

Your file "25015_f_padus" is a multipart shapefile, you need to convert the file to a single part shapefile before running the union tool. Go to Vector -> Geometry tool -> Multipart to ...
ahmadhanb's user avatar
  • 41.2k
7 votes

Dissolve only overlapping polygons in R using sf

Here's my sample data: > plot(bdf) If you only care about whether polygons overlap and how they form clusters, then use st_intersects: > st_intersects(bdf,bdf) Sparse geometry binary ...
Spacedman's user avatar
  • 65.6k
7 votes

Aggregating numerous polygons into one with PostGIS

You are looking for ST_Union; the function will attempt to dissolve the aggregated geometries: SELECT ST_Union(<polygons>) AS geom FROM <table> GROUP BY region ;
geozelot's user avatar
  • 30.6k
7 votes
Accepted

Merging and deleting with priority overlapping polygons in QGIS

First, run "Difference" from the Processing Toolbox and choose your Regions as Input and your Protected Areas as Overlay: This difference layer will now have some holes: Now run "...
MrXsquared's user avatar
  • 35.2k
6 votes

Add attribute from underlying polygon based on maximum shared area

I would suggest using the join attribute by location Here is a few images of the dialog you would encounter. Also, you could use the Spatial Query plugin which is now a core plugin in QGIS and the ...
whyzar's user avatar
  • 12.1k
6 votes
Accepted

How to self union a GeoDataFrame?

For the geometry you can use the unary_union (Shapely unary_union) predicate. The method will split all self-intersection geometries (Planar Graph) # unary union of all the geometries of the ...
gene's user avatar
  • 55.2k
6 votes
Accepted

Union of Polygons with slightly shifted coordinates

Thanks a lot to @Vince for the hint. Just added rounding (PostGIS: ST_SnapToGrid(geom, 0.000000001)) to my query and now it get's recognized as one polygon. Downside of this is that my accuracy of ...
Andreas Brauchle's user avatar
6 votes

Count overlapping features using Geopandas

It took quite a bit of head scratching, but I finally got there! Here is how you can do it in GeoPandas. def count_overlapping_features(in_gdf): # Get the name of the column containing the ...
Felipe D.'s user avatar
  • 2,719
6 votes
Accepted

Getting all of combinations of features found on two layers using QGIS

You can use Intersection tool in "Processing Toolbox Ctrl+Alt+T > Vector overlay" for this. For example, I have two layers as below: After using Intersection tool, you get a new layer: ...
Kadir Şahbaz's user avatar
6 votes
Accepted

Does UNION in PostGIS check for distinct geometries, or only other fields?

UNION does; row equality is checked on all returned columns and their types (using a type resolution sequence). A thing to consider: The implicit DISTINCT set operator here can be seen as partially ...
geozelot's user avatar
  • 30.6k
5 votes
Accepted

How to adapt a PostGIS query to modify the input table instead of creating a new table?

You cannot remove lines in the table you are currently selecting! But you can use your solution in "Edit 1" with a temporary table: BEGIN; CREATE TEMP TABLE temp1 ON COMMIT DROP AS SELECT ...
Elektordi's user avatar
  • 411
5 votes

Merge any and all adjacent polygons

I couldn't help thinking that your example is actually a raster and although you mentioned that you would like to merge based on "certain criteria (could be size)" I would like to give it a shot with ...
tilt's user avatar
  • 3,279
5 votes

ogr2ogr equivalent of QGIS Union

If you are interested in a "Spatial OR" between the layers 1 and 2 (i.e. intersection + difference 1-2 + difference 2-1), the union of the three elementary operations can be made with ogr2ogr in this ...
Antonio Falciano's user avatar
5 votes

Fast Union with Known Geographic Locations

As long as you are using PostGIS or the Python shapely module, your union operation is being computed by libgeos. GEOS already optimizes the union operation by taking advantage of the relative ...
dbaston's user avatar
  • 13.2k
5 votes
Accepted

Python script in ArcMap to fill a field in a shapefile based on information in other fields

def FillInfo(Info,Info_WB,Info_UESG,Info_GB,Info_Moo,Info_HHS,Info_PT,Info_SN,Info_SA): returnItems = [Info_WB,Info_UESG,Info_GB,Info_Moo,Info_HHS,Info_PT,Info_SN,Info_SA] returnItemsClean = [...
PhilippNagel's user avatar
  • 1,722
5 votes
Accepted

Summing Specific Features of Overlapping Layers

You don't necessarily need to merge your vector layers. Your title actually comes close to what you want, which is to perform a union. Starting with inputs layer a and layer b, both of which have a ...
jcarlson's user avatar
  • 3,910
5 votes

Compound contiguous links to lines in a network and find isolated lines

You probably want to cluster your lines by intersection - use ST_ClusterDBSCAN with eps := 0: SELECT *, ST_ClusterDBSCAN(<geom>, 0, 1) OVER() AS _clst FROM <lines> ; to assign a ...
geozelot's user avatar
  • 30.6k

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