QGIS - Mapping Ward Areas into Thiessen Polygons - qgis

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.

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.

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 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

Creating a map of boundary regions with Postgresql Lat/Long data

I have a Postgres database of U.S. zipcodes and their lat/long data.
My requirement is to divide these zipcodes into non overlapping regions.
All regions have some center zipcode. All regions grow outward, starting from it's center until they intersect with another region.
I do not know the radius/size of each region. All I know is the list of zipcodes that can be considered as centers of the regions.
How can I achieve this?
You can use a voronoi diagram. It's the dual of the delaunay triangulation.
You can also download zip code tabulation area shape files. See https://www.census.gov/geo/maps-data/data/cbf/cbf_zcta.html