Is there a way to find roads based on their length, or getting a list of roads in an area together with their lengths?
If is rather simple if you can tolerate importing OSM data first into PostGIS database with osm2pgsql utility. In that case read first
Basic query for getting a length of an OSM object is like
‘SPHEROID[“WGS 84”,6378137,298.257223563,AUTHORITY[“EPSG”,“7030”]]’) as
length from planet_osm_line where osm_id=-31332;
The query should be adjusted a bit to group all the road sections having a common name together.
select name, sum(ST_length_spheroid(transform(way,4326),
‘SPHEROID[“WGS 84”,6378137,298.257223563,AUTHORITY[“EPSG”,“7030”]]’)) as
length from planet_osm_line
WHERE highway in not null
GROUP BY name
ORDER BY name;
Not guaranteed that this is exactly correct and at least one problem remains: dual carriage ways would give the road length doubled. And of course this query is missing the spatial part limiting the area to what you are interested in.
There are probably also tools which can calculate lengths directly from OSM xml files.