OpenStreetMap logo OpenStreetMap

Email icon Bluesky Icon Facebook Icon LinkedIn Icon Mastodon Icon Telegram Icon X Icon

Discussion

Comment from Vincent de Phily on 11 March 2012 at 20:31

For that kind of calculation, load the exported data into postgres (many tutorials available on wiki for that) and run an sql query on it. For example, this one calculates total road length in the french city of Montpellier :

SELECT w.tags->'highway' as highway, count(*) as nb, sum(st_length(st_transform(st_intersection(w.linestring, poly),2154)))/1000 as km FROM (select ST_GeometryN(st_polygonize(w.linestring),1) as poly from relations r JOIN relation_members m ON (r.id=m.relation_id) JOIN ways w ON (w.id=m.member_id AND m.member_type='W') where r.tags ? 'ref:INSEE' AND r.tags->'ref:INSEE'='34172' GROUP BY r.id) AS v JOIN ways w ON (w.tags ? 'highway' AND ST_Intersects(poly, w.linestring)) group by w.tags->'highway' order by km desc;

It would obviously be simpler if you don't care about selecting just a part of your extract. Just don't ask *me* to detail the query to you, I only witnessed it in an IRC chat :p Look for postgis ans osmosis tutorials, and ask your question in help.osm.org instead of your diary.

Comment from Efried on 12 March 2012 at 13:48

Many thanks - I have to focus on buildings - not streets and should enlarge the query by adding two filters:
- orientation towards the street or the backyard
- orientation towards south east top south west
- add estimation of building height for calculation of facade surface
Is this doable?
many thanks

Log in to leave a comment