How can I get the length (brown marked part) of the "Road 7" inside the red polygon?

a busy cat

My start:

SELECT ST_Length(way) FROM lines WHERE road = "Road 7" AND ST_Intersects(line, polygon)?

With that, I get only the total length :( Someone has an idea?


It's necessary to calculate the actual intersection, e.g. http://postgis.net/docs/ST_Intersection.html

SELECT ST_Length(ST_Intersection(line,polygon)) 
| improve this answer | |
  • You beat me to it. +1 this should do it. – GIS-Jonathan Jun 12 '12 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.