Can you do a spatial join of multiple point layers with just 1 polygon layer as the target? - overlay

I have multiple layers of point features all for the same province. I want to do a spatial join to then classify certain areas (polygon layer) based on the total number of points, from all point layers, inside the polygons. Is there a way to do that, because on the spatial join wizard it only allows 1 feature layer. thanks

You can use the merge tool to combine all of your point layers into a single layer with all of your points, then run your desired spatial join using that single layer.

Related

Create Point Source Based on Polygon Tile Source

My goal is to have labels in the center of polygons.
Currently the polygons are being added via a vector tile source.
In order to have labels centered on polygons, it seems I must add a point source that has geometries representing the polygon centroids. (based on this answer)
When getting geometries via vector tiles, would it possible to dynamically create this point source, or must it be another vector source, one dedicated solely to centroid points?
The usual approach is to generate the labels separately, using geojson-polygon-labels.
Attempting to do it dynamically would be pretty tricky, although perhaps not impossible.

Intersection over union for rectangles with different orientation

I need to implement an algorithm in swift to find the intersection over union (IoU) between two rectangles with different orientations in 2-dimensional space. I could not find any tutorials or sample codes to teach how to implement such an algorithm.
Could someone provide relevant resources?
You can use O'Rourke algorithm for calculation of intersection of two convex polygons.
C and Java code is availaible on the page for book "Computational Geometry in C"
Algorithm traverses edges of polygons until it finds intersection (using
orientation test). After intersection it chooses "the most inner" edge from two possible next ones to build intersection core polygon (always convex).
When you have ordered list of vertices, you can calculate polygon area with shoelace formula.
To get area of union, we can calculate (thanks to Yves Daoust for hint)
Area(Union) = Area(P) + Area(Q) - Area(Intersection)
Alternatively to the very good solution of MBo/O'Rourke, you can use a sweep line approach.
For convenience, assume that one of the polygons is axis aligned. Then there are two "events" when the line hits the top and bottom sides of the aligned rectangle and four events when the line hits the vertices of the other (depending on the orientation, there are 8 possible permutations of the vertices).
The intersection of the rectangles occurs inside the vertical ranges defined by these events (you perform a merge of the two event sets) and there are up two six intersections to be computed between the oblique sides and the horizontals. For every event line, it is an easy matter to determine the X intervals spanned by both rectangles, and find their intersection or union. And the areas between two event lines are trapezoids.
To cope with rectangles in general position, you can
rotate both polygons to align one of them,
work with a counter-rotated coordinate system,
perform the sweep with an horizontal line anyway without moving the polygons; but then there are 8 events instead of 6 and up to 8 intersection computations.

QGIS - Mapping Ward Areas into Thiessen Polygons

I am designing a water supply distribution network. I have various pipes represented by Lines. Each start and end point of Line is a Junction (Node).
I have created Thiessen Polygons (Voronoi) using QGIS for each Junction (The Thiessen Polygon represents flow area for its corresponding Junction.)
I also have various Ward Boundaries (also represented as irregular Polygons), with each Ward having different Population.
My requirement : I want to calculate area of intersection between each Thiessen Polygon and each Ward and get a table, so that I can calculate the exact population within each Thiessen Polygon.
Example of Thiessen Polygons (The Dot within polygon represents corresponding Junction) :-
Example of Wards (also represented as Closed Polygons) :-
Final output desired :-
I have found the solution in ARCGIS -> Intersect Tool where it intersects Two Shapefiles (each having multiple polygons) and gives intersection results.
I think the same is not possible in QGIS as of now.

Area of intersection of connected components

I am doing a segmentation task using MATLAB. To analyze the performance of my algorithm, I need the area of intersection of each connected component in both images.
In what way are the connected components labelled in an image? Also, does PixelIdxList list all the linear indices of points that are a part of the connected component?
In what way are the connected components labelled in an image?
bwconncomp discovers the connected components by either using 4-(or 8)-connected neighborhood for 2D images or 6-(18, 26)-connected neighborhood for 3D images. Labels are enumerated starting from the left-top corner in 2D and in 3D (first slice).
Also, does PixelIdxList list all the linear indices of points that are a part of the connected component?
Yes. So, once both images are labelled, you can use intersect to find intersection between different labels. Also, you might want to read about Jaccard index.

matlab, measure of spatial spread

Having data points in a 3D neighbourhood (see attached picture), I would like to define a measure of spatial spread to accept or reject the data set as a candidate for further analysis. One measure could be how many of the cells in the 3D subvolume (the bounding box) are occupied by the neighbourhood. Another would be how the data stretches along each of the axis. Are there other and better criteria for measuring the spatial spread ?
Thanks