I have a table named Operation with multiple points as geom and I have created a buffer of 100m and added as a new column to the same table. I have another table named Residential which has multiple polygons, the goal is to find the percentage of polygons are inside each buffer and add it as a column in the Operation table. I am not sure how to proceed with this.
SELECT AddGeometryColumn ('public','operations','buffer',4326,'POLYGON',2);
UPDATE operations SET buffer = ST_Buffer(geom::geography,100)::geometry;
ALTER TABLE operations ADD COLUMN pts int;
UPDATE operations o
SET pts = (SELECT count(*) FROM supermarket s
WHERE ST_Contains(o.buffer,s.geom));
I have done till this, the following lines are not suited to get the percentage. How to approach this.
ALTER TABLE public."Operation" ADD COLUMN res_percent double precision;
UPDATE public."Operation"
SELECT
ST_Intersection(ST_MakeValid(r.geom),o.buffer) AS intersection,
ST_Area(ST_Intersection(ST_MakeValid(r.geom),o.buffer))/ST_Area(r.geom)*100))
FROM public."Residential" r, public."Operation" o
WHERE ST_Intersects(o.buffer,ST_MakeValid(r.geom));