adamfranco / curvature

Find roads that are the most curvy or twisty based on Open Street Map (OSM) data.
http://roadcurvature.com/
223 stars 37 forks source link

Add polygon filter to trim on regions. #46

Open adamfranco opened 7 years ago

adamfranco commented 7 years ago

The Geofabrik region extracts generally used as Curvature inputs uses relatively rough, low-node-count polygons to define each region and also include a slight buffer to ensure that no nodes for a designated region are missed. Because of this extra data in each extract, curvature will include roads that are outside of the borders of region generated as shown here:

screen shot 2016-12-20 at 8 22 37 am

In most cases, this simply results in duplicate roads (one in each output file) that really should just be in one or the other (A). In other cases, this data will join roads into longer segments that cross borders and significantly reside in both regions (B):

screen shot 2016-12-20 at 8 30 12 am

The main goal is to filter out roads that really should reside in only one region (A). This could be done in a filter step by comparing each way segment to a more detailed border, such as the Mapzen OSM Border downloads. If the ratio of length inside the border is less than the ration outside (and there is less than some threshold inside the border e.g. 1km), then exclude the road.

For situation (B), filtering could happen prior to curvature summing to allow only the in-border ways to be included in the curvature tally. Alternatively, these could be left in both regions or added only to regions with the longer or highest-curvature portion.