Technologies: PostGIS, QGIS
I have a vector box named "study_area", and another vector data "floodplain". Now I need to clip the floodplain vector data to produce a floodplain layer that is within in the study area. I am required to use postgis, writing queries for this specific job.
However, I checked the doc, it seems like the st_clip function only works for rasters.
Here is my attempt:
select r.geom as clipped
from study_area as s, usrname."Regulatory_Floodplain" as r
where st_within(r.geom, s.geom) or st_intersects(s.geom, r.geom)
The problem is that it is not entirely in the box:
Any alternatives? Any help will be appreciated, thanks!
You probably want ST_Intersection
function, something like
select st_intersection(r.geom, s.geom) as clipped
from study_area as s, usrname."Regulatory_Floodplain" as r
where st_intersects(s.geom, r.geom)