I was able to project the point location (ad.shp) to the nearest street (line.shp) like this.
My approach was like this. I used ST_ClosestPoint() to iterate this for every point location within a distance of 10 meters and it worked well! (Yes, suggestions for improvements are always welcome).
Select ST_ClosestPoint(line, pt) As closest_pt_line
From
(Select ad.geom As pt,
st.geom As line,
ST_Distance(ad.geom, st.geom) As d
From ad, st
Where ST_DWithin(st.geom, ad.geom, 10.0)
Order By d
) As foo;
Based on this interpolated point at street layer I want to calculate the width and length of street in both direction. The scenario can be visualized as follows:
The length of street needs to be calculated in both direction based on the interpolated point and street width needs to be calculated with reference to building polygons. I am aware of ST_Length() in Postgis but it returned the length of whole linestring rather than length 1 and length 2 (as shown in figure). Any advice for how to calculate street lengths and width in PostGIS?
UPDATE:
The answer of @kttii helped me to compute street width and lengths of the segments on both side of projected point!