How do i find all the polygons within n radius from a point in QGIS? - qgis

I have two layers, the first has hundreds of polygons all with a unique id.
The second one has thousands of points all with a unique id
Each point has a "area of influence" or a radius of 2 miles.
I need a "list" of all the polygons touching (no need to fully cover) each point's area of influence.

Related

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.

Generate geometries from each intersection and apply aggregation to row

I'm trying to figure out how to use PostGIS (since I have my polygons stored there already) to generate a set of nonoverlapping polygons.
The source table has two columns (geometry and occurences), geometry is always a valid polygon, occurences is an integer.
The polygons in the table can overlap. For all the overlapping regions (there can generally be more than 2 intersecting polygons) I would like to generate a new polygon (as with ST_Intersection) AND apply an aggregation to the occurences column (MIN/MAX/AVG would be enough)
I can find pairs of overlaps by using ST_Intersects and handle the pairs, but I have trouble reducing multiple intersections.
In the following example, the 3 source rows would actually end up being 7 separate polygons (imagine the circle is actually a POLYGON geometry), the occurences then would be averaged from all interesecting polygons in each case.

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.

Qgis how to distribute points inside a polygon

I´m new to QGIS, lately I got 2 Shapefiles one showing the polygons for some areas that represent street blocks, and another shapefile with the points that represent the number of comercial stores in the area, so sometimes we have one and others we have 90, depending on which street the survey was done.
The problem is that the points layer shows only one point where there should be more than one, that is because all points corresponding to a certain street or block are asigned the centroid of that polygon as coordinates. Is there a way to distribute all points automatically inside the polygons so if there is only one the points stays in the centroid and if there are more the points shift position in order to show how many points are exactly? Added a screencap for references

Find co-ordinates where LineString intersects a Polygon border in turfjs

Is there a way in Turfjs to determine the co-ordinates at which a LineString intersects with the border of a polygon?
There's a number of ways to find out if a point is within a polygon and a number of ways to find out if a point is on a line and so on, but I can't seem to figure out a way to ask "at what point does this line intersect this polygon's border".
I could enumerate the points in the polygon using a line intersection algorithm to find that point but I was wondering if there's a more "turf" way of doing this.
For context, I've loaded a GPX track and want to estimate the location/time at which the track enters/exits a defined area.
Because a GPX track only records locations at specific intervals it usually the case that pN recorded at time tN is outside the area and pN+1 recorded at time tN+1 is inside the area.
If I can get the point at which line (pN, pN+1) intersects the polygon's border I can estimate the exact time the track crosses into the polygon.
Ultimately, turfjs does not seem to have an API for doing this.
I was able to get the answer I wanted by enumerating the points in the polygon from the GeoJSON object to construct a sequence of line segments and then I used maxogden/geojson-js-utils linesIntersect function to test for intersection points.
I don't see a Turf function that does exactly that, but there is intersect, which finds the area of intersection between two polygons.
You could:
Construct a polygon by joining the line to itself reversed (so ABC becomes ABCBA)
Find the intersection of ABCBA and P, the original polygon using Intersect.
The intersection should be a zero-area polygon that is the part of ABCBA inside P. Somehow compute the length of it (strangely there's no perimeter function).
Subtract that length from the original length of ABC.
Not exactly elegant, true. :)
EDIT
Tried this. Turns out Turf-intersect doesn't return intersections if one of the polygons is zero-area.