49 votes

Understanding Join Attributes by Location in QGIS?

Join Attributes by Location concatenates the following set of methods to compare geometries: intersects if the intersection of both geometries is not empty contains if the second geometry is ...
  • 24.6k
32 votes

Join spatial point data to polygons in R

over() from package sp can be a little confusing but works well. I'm assuming you've already made "A" spatial with coordinates(A) <- ~longitude+latitude: # Overlay points and extract just the code ...
  • 14.5k
27 votes
Accepted

Understanding Join Attributes by Location in QGIS?

Don't think the QGIS docs has something as detailed as what is shown in the link in your comment (here is the link for English speakers). I would assume the terminology would be pretty much similar if ...
  • 72.9k
25 votes
Accepted

One-to-many joins on a feature class to a table

To multiply the features do this (available to those who have ArcGIS 10.1 or above). Place the features and table into the same file geodatabase (you must convert Shapefiles/Excel/DBF files into the ...
21 votes
Accepted

geopandas spatial join extremely slow

adding the argument predicate='within' in the sjoin function speeds up the point-in-polygon operation dramatically. Default value is predicate='intersects', which I guess would also lead to correct ...
20 votes

More Efficient Spatial join in Python without QGIS, ArcGIS, PostGIS, etc

Additionally - geopandas now optionally includes rtree as a dependency, see the github repo So, instead of following all the (very nice) code above, you could simply do something like: import ...
20 votes
Accepted

GeoPandas spatial join and count

Try: import geopandas as gpd import pandas as pd polys = gpd.read_file(r"C:\Test\Shapes.shp") points = gpd.read_file(r"C:\Test\POI.shp") dfsjoin = gpd.sjoin(polys, points) #...
  • 55.3k
18 votes

geopandas error "minimums more than maximums"

For the benefit of anyone else searching for this error message, one thing that can cause it is attempting to do a spatial join where the point coordinates contain nulls.
  • 281
16 votes

geopandas spatial join extremely slow

What's likely going on here is that only the dataframe on the right is fed into the rtree index: https://github.com/geopandas/geopandas/blob/master/geopandas/tools/sjoin.py#L48-L55 Which for an ...
  • 453
15 votes
Accepted

How to ignore invalid geometries in performing spatial join in QGIS 3.0?

From Settings -> Options -> Processing tab, expand out the General setting. Look for "Invalid features filtering" and set it to "Do not filter"
  • 26.5k
13 votes

Spatial join versus classical join

The main difference is that in a classical join, inner (equi), left or right the joined fields or field must match exactly on both sides of the join, ie, in both tables you are joining. In a spatial ...
  • 13.3k
13 votes

geopandas spatial join extremely slow

The question asks how to take advantage of r-tree in geopandas spatial joins, and another responder correctly points out that you should use 'within' instead of 'intersects'. However, you can also ...
  • 285
12 votes
Accepted

One-to-many spatial join with results in one row in QGIS

There is a possibility of using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... Let's assume there are two polygon layers: 'Layer_A' (brown) and 'Layer_B' (...
  • 24.6k
11 votes

Join CSV file to shapefile

Here is how you can do it in R using sp::merge library(raster) # read data p <- shapefile("path/file.shp") d <- read.csv("path/file.csv") # merge on common variable, here called 'key' m &...
11 votes
Accepted

Getting concatenated attribute values from Spatial Join

One solution is to create a Virtual Layer and write some SQL. Type the following query into the Query section of the dialog: SELECT c.geometry, c.CITY_NAME, group_concat(z.code) AS ZIP_ids FROM ...
11 votes
Accepted

Count number of points by name within distinct polygons

Try: SELECT polyname, count(pid) FILTER (WHERE pid='w') AS "w", count(pid) FILTER (WHERE pid='x') AS "x", count(pid) FILTER (WHERE pid='y') AS "y", count(pid) FILTER (WHERE pid='z') AS "z" ...
  • 55.3k
10 votes
Accepted

Join / merge lines that touch and intersect in QGIS

In QGIS Plugins you'll find a 'merge lines' plugin, which at first sight seems to accomplish what you are after. cited from description: MergeLines Simplifies the topology of a line network by ...
10 votes

Creating spatial join between points and polygons in GeoPandas?

There is not any bug in 'sjoin' method. To realize this, you also need Rtree python module (in my case installed with easy_install) and libspatialindex library (from my Debian Linux repository). ...
  • 27.1k
10 votes

Joining attributes by the biggest overlapping areas in QGIS

The "Join Attributes by Location" algorithm from the Processing Toolbox has a switch to do exactly this: The type of the final joined layer. One of: 0 — Create separate feature for each ...
  • 26.5k
9 votes
Accepted

Difference between 'join' and 'merge'?

When to use join: When there is a one to one relationship between two distinct tables or geometrics (based on join field or spatial relation) Used to append new field/columns to table (result = table ...
  • 34.8k
9 votes
Accepted

Join spatial point data to polygons in R

The point.in.poly function in the spatialEco package returns a SpatialPointsDataFrame object of the points that intersect an sp polygon object and optionally adds the polygon attributes. First lets ...
9 votes
Accepted

Sum line lengths for each grid cell in QGIS

Create a polygon grid using the Vector Grid tool instead of lines. Make sure to check the polygon output. Once you have a polygon grid (also known as fishnet), you can use the Sum line length tool ...
  • 8,398
9 votes
Accepted

Getting points-touching-a-line attributes back to lines layer using QGIS?

Although @radouxju answer is valid, I will explain it a little more detailed. You need to make sure that the polyline feature is split exactly above the point locations. Use Join attribute by ...
  • 36.7k
9 votes
Accepted

Setting list of fields to field mapping of spatial join using ArcPy?

To manipulate the fields, their order, names, and other properties it is necessary to use the arcpy.FieldMappings() class. It is not very easy to get to know them and start using, so I've added extra ...
9 votes
Accepted

Spatial join if percentage of area is within

You can try below query by getting the intersected area of both geometries and the total area of Parcel geometry, then get the percentage and compare it 90%: CREATE TABLE test_join AS SELECT t.*, m.* ...
  • 2,855
9 votes
Accepted

Aggregating result of many to many join of points closest to line in QGIS

Giving you only one point id is sensible. Otherwise, join operation would generate hundreds/thousands of columns in the line layer for each near point. One solution would be to add all near point ids ...
8 votes
Accepted

How to do a spatial join in PostGIS that returns on the minimum value of point intersecting polygon?

First use a window function to get the ordered rank of the dem_points. In a second step filter the dem_point with the lowest dn by the rank. SELECT osm_id, gid, dn FROM ( SELECT b.osm_id, ...
  • 399
8 votes

Speeding up QGIS spatial join?

Add a spatial index to each of your shapefile layers: Layer > Properties... > General then Create spatial index. Another way is to create them for all the layers in one go: Vector > Data ...
  • 855
8 votes
Accepted

Creating spatial-join which will calculate sum of values in certain field behind attribute in ArcMap?

This can be done by something that is called Merge rule - not very easy to find, I think. Use the Spatial Join geoprocessing tool and choose the Merge rule to be Sum for the needed fields (right-...
8 votes
Accepted

Get points within maximum distance from any point in GeoPandas

Assuming you have one geoseries with Points (for example you want to compare Point 1 to Point 2, Point 1 to Point 3,... ): import geopandas as gpd from itertools import combinations from shapely....
  • 55.3k

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