nst-guide / data

Create map waypoints and layers from open data sources
https://nst-guide.github.io/data/
GNU General Public License v3.0
6 stars 0 forks source link

Trail Network #53

Open kylebarron opened 4 years ago

kylebarron commented 4 years ago

Create a topologically-connected trail network

Outline

  1. Get approximate trail geometry from any source. Say Halfmile or even USFS for the PCT, etc for other trails.
  2. Using the approximate trail geometry, download all trails from OSM for an n-mile buffer around the trail. I now have an OSM network of trails, which are generally well-connected. (You could have a validating function here that searches for trails that are very close or intersecting but don't have an intersecting node).
  3. Have a validating function that finds areas of the two tracks that are far from each other. Say for every point on the OSM track of the given line, find the closest point on the Halfmile/other track and record where the tracks are >100m apart from each other.
  4. Validate that the OSM trail relation is well-connected, i.e. that every way of every part of the relation is connected to the one before and after, so that there are no gaps.
  5. Find trail junctions
  6. Find water intersections.
  7. If you wish to use the Halfmile data as the main data source in the app, then you need to figure out a way to take the OSM network of trails and adjust everything for use with the original HM track.
  8. Validate that final network of trails is connected.

When running Tippecanoe, you need to make sure you use --no-simplification-of-shared-nodes so that lines share a node. Then you can probably have simple routing using the vector tiles.

Notes:

Uses

Ref: #45, #46, #41, #5, #4

kylebarron commented 4 years ago

As of https://github.com/nst-guide/data/commit/452a299f4896861a46124d0d0f9db364a9f62ac1 I have the approx trail geometry, and have code to make networkx graphs much more quickly by using geofabrik extracts.

For finding trail junctions, you can just iterate over nodes that have _trail=True, and very quickly do G.edges(node_id, data=True) to see the metadata of the edges that connect to that node.

For finding water intersections, you'll probably want to check out something like get_nearest_edges for springs. https://osmnx.readthedocs.io/en/stable/osmnx.html#osmnx.geo_utils.get_nearest_edges