Find the flattest route between any two points in SF

flattensf.com
ishan0102
yesterday
308points
114 comments

Comments

jez•yesterday
It would be neat if it there were an option which added distance and elevation gain, but minimized the grade.

For example, a route from SOMA to Nob Hill can be made flatter by approaching from either the east or west. Technically the "flattest" as measured by elevation gain between the two is straight up Taylor from Market, but it's much nicer to bike to the top of Nob Hill by going out of the way (e.g. Polk → California, Embarcadero → Broadway, etc.)

almstimplmntd•5 hours ago
a steepness penalty could make sense!

your example (from market & taylor to the top of nob hill) is a nice illustration: (1) straight up taylor is 229 ft of climbing at 25%, (2) via polk and california it's 251 ft at 13%.

as you probably noticed, we only look at the total elevation gain, so taylor "wins"... but I see the argument for preferring an extra 20ft of a more gradual climb.

cowthulhu•yesterday
I suspect that this would result in absurdly long routes. Imagine trying to go up a mountain while minimizing grade... you'd end up zig-zagging back and forth endlessly.
Serishmus•yesterday
Isn’t that exactly how you build a trail up a mountainside? They are usually a series of switchbacks.

Most people on most bikes can only take so much grade before climbing becomes impossible. A maximum grade setting would be very helpful for that exact reason.

cowthulhu•yesterday
Oh, yeah, I interpreted the parent comment as "minimize the grade" but if it's instead "keep grade below threshold" (for reasonable thresholds) that would make more sense.
avani•13 hours ago
A minimize grade and grade cap would be incredible for folks pushing wheelchairs (or strollers even!).
frollogaston•yesterday
I feel like even if the distances are equal, it's faster to walk a bike up a steep grade and bike the rest flat than it is to bike up a moderate grade the whole way. This topic has probably been discussed somewhere else.
maccam94•yesterday
People can generally only output their max power for short durations. The output level they can sustain is generally much lower. I bet you could try to model higher limits for short distances, but what those should be could vary greatly depending on personal fitness.
frollogaston•20 hours ago
I think that too favors walking the bike up the incline. Anyone able-bodied should be able to do it, some faster than others, but biking up an SF incline is more hit or miss, especially when considering different bikes.

My reasoning for the bike-hike being faster is that legs are designed for it. Legs are only inefficient on flatter ground because you have no equivalent of high gear (like extendible legs), so all that torque is going to waste.

sokka_h2otribe•8 hours ago
Uhh, excuse me? Legs are inefficient on flatter ground because they don't have wheels.

Legs have to start, go up, go down, stop.

Wheels go brrrrr.

frollogaston•3 hours ago
That's some of it too, but in a way legs aren't all that different from wheels in how they work. Most of it is the gearing. Like there's a gear on every mountain bike that will make your feet go down at the same intervals as walking. That sucks on flat terrain. Legs are also not perfectly designed to push pedals, especially for people who don't bike often.
ninju•7 hours ago
I believe the "wheels on the bus go round and round" :-)
FeepingCreature•18 hours ago
BRouter models this as inertia, I believe.
kyleee•yesterday
But hike a bike is no fun, especially if trying not to sweat
Karliss•19 hours ago
Unless you are on foot (and even then) the route needs to follow existing roads, you can only zig zag as much as existing roads do it not endlessly.

And almost any practical routing system will have a mechanism for tradeoffs of different aspects. Often there is a distance/time tradeoff which directly relates to speed on corresponding segments. But the tradeoff can also be in the form of "on average x seconds spent waiting green light in each intersection or time to stop before railroad crossing. So there is no reason for a system optimizing grade to completely ignore all other factors, it's just a question of weights and curves of each of them.

lanstin•13 hours ago
Like the ascent to Mt. Hamilton (southern Bay Area). You can see the peak for like an hour but so much twisting back and forth, going mostly perpendicular to the max gradient. It is an old road and hence graded for mules to carry up telescopes.
RugnirViking•17 hours ago
well. That or a nice spiral! :)
danserfaty•yesterday
It's not accurate. I mapped it from my house on Cabrillo St in the outer Richmond to 4th avenue and it says I need to climb 25th avenue then walk Geary instead of correctly telling me to use 23rd avenue that is completely flat.
jeffbee•yesterday
I think this comes down to the DEM they are using. I think it would have come out better if they had used USGS 3DEP DTM at 25cm.

Edited: which apparently is hosted for free on AWS S3.

almstimplmntd•yesterday
ah, I think this is related to SF's "Slow Streets" program and a genuine bug in the parser.

Cabrillo is a Slow Street, and the parser read its "destination-only" tag as closed to pedestrians, so the tool couldn't see the street at all (and started you a block over?). fixed and deployed; your trip should now go Cabrillo → 23rd → Geary.

jazzyjackson•yesterday
“genuine bug in the parser” -> red flag for slop for those keeping track at home
bigmadshoe•13 hours ago
Also "fixed and deployed; your trip should now go Cabrillo → 23rd → Geary". The snappy sentence at the start and the unicode arrows are both pretty big flags for AI writing.

Obviously it's fine to use AI for projects like these, but copy-pasting the response from a coding agent doesn't quite sit right with me.

Doctor_Fegg•yesterday
No, as someone who writes a cycle routing engine by hand, this stuff is endemic when dealing with the trifecta of complex traffic regulations, inconsistent mapping data, and user preferences.
mschuster91•yesterday
Looking at the repository [1], there are very strong signs for this being LLM generated. The README.md just smells of LLM tells, and Claude Code is being listed as "contributor".

I agree that the tone the parent commenter used wasn't the nicest but unfortunately, factually he is correct.

[1] https://github.com/almostimplemented/flattensf

dekhn•yesterday
No need to be a jerk.
pokpokpok•yesterday
The wiggle!

(in honor of my old commute, which I miss)

https://flattensf.com/#t~-122.40850~37.77493~-122.50940~37.7...

askjdfksdbfhk•yesterday
There's a weird thing going on at 22nd and San Jose in the Mission, where it doesn't seem to understand that you can simply continue down 22nd, but instead takes a hook down San Jose before backtracking. I see some other weird discontinuities like this as I click around.

I have to say that the Claude UI has made many inexplicable decisions here, including (but not limited to) the mysterious color coding, the confusing continuous slider over a discrete set, and the weird positioning of the height labels in the altitude graph.

DrProfresher•6 hours ago
This is super cool! The map and UI are super clean, well done!

This makes me want to take out my longboard.

scaredginger•yesterday
This is great. Since SF is mostly a grid, I used to use the heuristic of only choosing paths that wouldn't take me further from my destination, avoiding going downhill but choosing the shallower uphill climb if a choice is given.

Other than knowing the direction of my destination, it only used local information

geor9e•yesterday
It's telling me to bike on Geary and Divisadero. No thank you I'd rather stay alive.
almstimplmntd•yesterday
fair point! it just doesn't know about bike lanes yet, I’ll see about getting the SFMTA bikeway network map from DataSF.
bwnkl•yesterday
Nice visualization. For proper turn by turn directions, Valhalla [1] could help. It has elevation support so this could theoretically be built with it[2], or you just send the shape of your flattest route and it annotates it with guidance.

[1]: https://github.com/valhalla/valhalla

[2]: Currently it only supports 30m resolution for elevation unfortunately

laurencerowe•yesterday
This seems to have the same issue I saw with Google Maps where it directed me along 29th St from near Mission Bernal Safeway to Diamond Heights Safeway. This includes a 22.7% grade! It's much faster and easier (at least on my cargo e-bike) to take the longer way around up Clipper St (12% grade).

The bug seems to be apparent when you set the end point at Duncan & Diamond Heights Blvd and the start point directly north along Clipper.

This route seems to maybe save 1 ft of climbing but goes up a 23% grade.

https://flattensf.com/#t~-122.43968~37.74865~-122.44028~37.7...

Half a block up the street it takes the sensible route with only a 13% grade. (Between the two different starting points is 41ft of climbing.)

https://flattensf.com/#t~-122.44087~37.74864~-122.44028~37.7...

almstimplmntd•yesterday
good point.. the slider trades distance against total climbing and nothing else. steepness is currently reported but not optimized.

seems like a worthy addition to the objective!

cheeaun•yesterday
Cool, I used to build this https://github.com/cheeaun/steepless (2014)