I would like to calculate the number of unique kilometers of roadways in my city. More generally, I wish to sum the distance of every road within a bound, for simplicity a rectangle will do.
Is this possible using the Google Maps suite of APIs? If so, how would you go about doing it? If anyone has any resources related to this type of problem, I would be interested in reading them regardless of language (or even solutions with other mapping tools).
Bonus points: A general solution to this problem that can be applied to the pre set "cities" (example) that appear in Google Maps with well defined city limits.
You can use OpenStreetMap to calculate the total road length of a specific country or geographic area. There are multiple solutions available, based on multiple similar questions already asked.
Approach 1 from Total road length in Kilometers for a country at help.openstreetmap.org: Use the Perl script osm-length-2.pl. There is an example at a mailing list post.
Approach 2 from Actual road length of exported map at help.openstreetmap.org: Import your data (the planet or an country or area extract) into a PostGIS database, then use the following queries proposed by Frederik Ramm:
SELECT way AS clip INTO clipping_polygon FROM planet_osm_polygon WHERE boundary='administrative' AND admin_level='8' and name='My City'; SELECT name, highway, ST_INTERSECTION(way, clip) INTO clipped_roads FROM planet_osm_line, clipping_polygon WHERE ST_INTERSECTS(way, clip) AND highway IS NOT NULL; SELECT highway, SUM(ST_LENGTH(way::geography)) FROM clipped_roads GROUP BY highway;