Quantcast
Channel: Question and Answer » postgis
Viewing all articles
Browse latest Browse all 371

How to calculate width and lengths of street layer in Postgis/PostgreSQL?

$
0
0

I was able to project the point location (ad.shp) to the nearest street (line.shp) like this.

Point on line Interpolation

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:

Visualization of street lengths and width

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?


Viewing all articles
Browse latest Browse all 371

Trending Articles