Hacker News new | past | comments | ask | show | jobs | submit login
City Roads – Draw all roads in a city at once (anvaka.github.io)
668 points by jordinebot on Jan 22, 2020 | hide | past | favorite | 143 comments



Hey there, I'm the author of the tool!

Just wanted to thank you for the comments, feedback and shares! I 'm very happy!

PS: If you liked that project you may find my other stuff interesting: https://twitter.com/search?q=from%3Aanvaka%20min_retweets%3A... - it's just a hobby but I love it :D


I like the interaction design a lot while loading the data.

The first time it took very long and after a while it said 'still loading'. Then after a while 'sorry this is taking so long'. And then 'trying another server'.

This is great interaction because the user knows what is going on and the app is still busy.

Great job!


Small feature request: Being able to rotate the image. For some cities, the "canonical" map is not vertically aligned with north (e.g. Barcelona, in maps usually the coast is horizontal, so north is pointing top-right).


This tool has some insanely good performance -- kudos! What did you build it on?


Thank you!

The rendering is done with WebGL. I wrote a silly 2d renderer to learn more about the platform, and never documented it. Thought it would not be very useful.

Ended up using it in a lot of tiny projects, but didn't have chance to document it yet. Here it is https://github.com/anvaka/w-gl


I don't know if open street data let's you monetize like this, but consider adding a link to Shutterfly or some similar site that would let the user get their road network of choice be printed out on a mug or t shirt.

A site featured on hn a few weeks ago which showed height renderings of various locales let you do something like that.


This is already incorporated into the site. After the roads render, click "Customize", then "Onto a mug" and a link to zazzle.com will open to order a mug.


OpenStreetMap data license (ODBL) allows any use of renderings as long as attribution is present, and that modifications to the data have been made available under ODBL.


That one is also from anvaka :)


Funny. I wonder if the similar visual styles led me to connect the two despite not even remembering what exactly the terrain height mapping one was.

Now I feel kind of silly suggesting to this person a great idea that was actually...their own.


Do you remember the site that was submitted?


Peak map: Visualize the elevation of any area using a ridgeline chart

https://news.ycombinator.com/item?id=21968874


Bonus points if you let me add UTM or Lat+Long coordinates to have marks appear for the peaks I've bagged on the peak map. Then I can buy a mug or print a poster that lists all the peaks I've bagged or intend to bag.


Oh! This one is fun :)!


Can you export it to SVG? I can see this really helping Wikipedia editors.


Done!


Thanks!


Your projects are awesome anvaka! Please continue doing those!


Sincerely thank you. I'm so happy to know this!


Yeah it's really nice! :) However i think there should be an option to disable showing sidewalks for pedestrians, so only roads for cars should be seen then. It would be nice to see where you can drive your car ;)


Very cool! It would be nice to be able to group multiple cities in one map. Greater London and the City of London are listed separately so Greater London has a big hole in the middle.


Yes, this would be great.


Well done. If possible, can you add functionality for:

- Pre-saved color swatches to cycle through, like those at color.adobe.com/trends

- Custom cell phone cases. A bunch like casetify offer affiliate revenue.


I like the minimalism of it. That said, I'd be happy if you exposed road segment classes (I believe OSM maps have that) for styling to give main streets or highways a bolder tone.

Kudos :)


Tokyo (massive map) seems a bit buggy, and there's several distinct groups of roads loading. Awesome tool nonetheless!


It seems they're islands that are also part of Tokyo. From[1]:

> Also within the administrative boundaries of Tokyo Metropolis are two island chains in the Pacific Ocean directly south: the Izu Islands, and the Ogasawara Islands

[1] https://en.wikipedia.org/wiki/Tokyo


What are the copyright terms on these maps? What if someone wanted to use these on custom t-shirts and posters to sell?


The OSM data license would still apply here, meaning you must attribute them [0].

As for the visuals of this map, chances are the MIT license for the repository applies to it as well [1] [not a lawyer].

0: https://wiki.openstreetmap.org/wiki/Legal_FAQ#3a._I_would_li...

1: https://github.com/anvaka/city-roads/blob/master/LICENSE


Would you happen to support Canberra, Australia? Or is there a way to request a city if it's not listed?


Try "Australian Capital Territory". The search is using some sort of metadata from OSM, which is mildly quirky.


Should work a bit better now


I found this bug too!


It's pretty cool mate. Gonna make a wallpaper with it.


Yay! I'd love to know how it goes! I'm myself not sure what would be the best resolution and line thickness to do wallpapers. If you find something appealing - please share?


Would love to see a version that renders train/street car tracks


Or bike lanes!


It already renders bike lanes - it displays all highway classes, from freeways to walking trails.


There are some bike apps that can do this though. With GPS support for navigation :-)


It's interesting to note the size of the download for a city. Guess it's related to the complexity of the road network, not necessarily the number of roads. Interesting to think about the "entropy" of a city's network and compare between cities. For instance, Sydney AU is 25Mb, but NYC is only 11Mb. Even tho population of NYC is ~e x Sydney.


Check out Sao Paulo - it was over 500MB! Was very impressed that the map still rendered and was responsive on my 4 year old laptop too.


I love how elegant it is!

Unfortunately it can't seem to find most cities I try. Just one example, typing "New Hartford" only finds one in Iowa, instead of listing all of them [1]. Most other medium-sized towns I tried show no results at all.

I'd also love it if there were a way to export as SVG's -- these seem like they would make amazing posters to frame.

[1] https://en.wikipedia.org/wiki/New_Hartford


Thank you!

I checked here https://nominatim.openstreetmap.org/search.php?q=New+Hartfor... - looks like all other `New Hartford` have type "node" in the database, which doesn't give boundaries of the cities.

We are thinking about fallback here: https://github.com/anvaka/city-roads/issues/7 but what might work better in short term: try entering a county name, and then zoom in onto the place. It is not as convenient as having a city boundaries, sorry about that.


Ah the counties work great! Never even would have occurred to me. And honestly, for many medium-sized towns, the county is more intuitive boundary anyways.

Since it's not clear you could search by county, may I suggest including that as a tip or something? Otherwise it gives the impression the site is broken somehow.

Or if it's possible, to find the smallest containing item that does have boundaries, whatever it is. (I don't know if OSM supports that performantly?)


It's not just small cities that counties are useful for - Los Angeles (the city) is really fragmented, snaky thing while Los Angeles (the county) is actually geographically coherent.


I tried Inverness, but strangely it only found those in the new world, not the original in Scotland.


Seems to be struggling with some of the nations in the UK. I can get London (England) and Swansea (Wales) no problem, but Edinburgh, Dundee, Glasgow (Scotland) etc. don't work. Nor do Derry, Belfast etc. (Northern Irish cities).


The data is coming from https://nominatim.openstreetmap.org/search?format=json, and it appears that it doesn't do any keyword searching - so if you type "edinburgh" it only finds regions which start with edinburgh. Typing "City of edinburgh" will find the correct council region.

https://anvaka.github.io/city-roads/?q=city%20of%20edinburgh...


Neat, but this does not seem to be all roads, it seems to be everything tagged highway=*.

Specifically, non-motorized walking/biking paths and mountain bike trails (highway=path) are rendered.

Ref: https://anvaka.github.io/city-roads/?q=Marquette%2C%20MI&are...


In my case, I noticed many driveways were rendered when I did my town.


Yep! That's because those too are highways.

See this for reference: https://wiki.openstreetmap.org/wiki/Key:highway

I believe a driveway would be highway=service.


My hometown also got every tiny little hiking trail & path, walkway bridges and floating quays in the marinas :) I enjoyed this a lot.


Same here, was interested to see it was only certain suburbs which had the driveways mapped.


Do you guys think it would be worth removing the foot paths? Someone here proposes to remove them altogether: https://github.com/anvaka/city-roads/issues/3 - I'm not sure yet which direction would make more sense?


I don't know if it would complicate the UI too much, yet having a toggle for them would be amazing. There are solid arguments each for having them and not, for example they're perfect for trail systems, yet horrible when it comes to sidewalks which turn each road into a triple line.


Maybe you need some checkboxes in the Customize panel.

SVG export would also be pretty useful.


Beautiful! I tried it with quite a few cities. Most of the cities hardly look as if they were planned out!

A few from the Wikipedia list [0] looks nice though.

[0]: https://en.wikipedia.org/wiki/Planned_cities

Quezon City: https://anvaka.github.io/city-roads/?q=Quezon City&areaId=3600106569

Chandigarh: https://anvaka.github.io/city-roads/?q=Chandigarh&areaId=360...

Singapore: https://anvaka.github.io/city-roads/?q=Singapore&areaId=3600...


Try "Adelaide, South Australia". It was an actual planned city, and the city centre for the most part is a very easy to navigate grid. North Adelaide (the other grid you'll see to the north west just above it) also planned in the same way, but just across the river and smaller. Probably one of the best "planned cities" I've seen on things like this.


Ah Chandigarh. Good choice. The beauty of this city is evident in even this minimalist drawing.


It's really simple looking, but I entered my city, and I just love the graphic that was rendered. Is there any chance of making it produce SVGs to download?


Yes, but it is (as of this moment) an experimental feature. Add "?svg=1" to the end of the URL to enable this feature [0].

[0]: https://github.com/anvaka/city-roads/issues/4


Would love to find something like this for rural areas. Maddening sometimes how details disappear from most online maps based only on zoom level rather than on feature density.


You should check out OsmAnd [1] and their pro client, which is FOSS [2]. The maps are downloaded in svg from OpenStreetMap (available offline) and the app has a ton of features. Also i'm not sponsored, I just find the whole thing very useful

[1] https://osmand.net/ [2] https://f-droid.org/en/packages/net.osmand.plus/


as long as there is openstreetmap data for it It should work for rural areas as well :)


was able to do Cape Breton Island [1], maps look really nice!

[1]: https://i.imgur.com/I7q7Ttv.png


The site times out, YC has struck.

It says it is contacting openstreetmaps, but the global mapping community is called openstreetmap (no 's').


Will fix the name! Thanks for catching


It seems to be missing most of Scotland. No Glasgow, Edinburgh, Dundee, Perth, or Inverness. It does have Stirling, Aberdeen, and Falkirk. It's also missing parts of Australia: no Perth, Brisbane, Darwin, or Alice Springs.


It would be really neat to be able to set a custom resolution to render as a .png image. Like e.g. if somebody wanted to create a poster.


While this may be possible some day, you can export today as vector file and then use https://ezgif.com/svg-to-png tool to save the SVG at any resolution. Would this work?


Awesome project, love the output!

My wishlist item would be to have an option to render an additional x miles around the city limits boundaries to help incorporate communities that have the same city in their address but are technically not within the city limits.


Can someone either explain the use case for this to me, or explain what I'm missing? Too small to be of any use to me, no street names... maybe it's just a "cool" thing you put on a mug or get printed on a T-shirt?

I'm probably just not in touch with my inner artist and am too quick to look for the functional / business purpose of this.

By the way, really solid work and very kind of the author to share this. I can still appreciate it even if I don't see how I'd ever need to use it.


Okkk now how do I import this into Cities Skylines



Shameless plug for https://abstreet.org. (Importing any city from OSM still needs lots of work, though.)


My Girlfriend is an architect and she finds this tool great :) She asks if it would be possible to export these maps as .dwg file


The data is coming from OpenStreetMap, via http://overpass-api.de/

It's kind of overwhelming, but there's all sorts of tools that can take OSM data and do something with it.


Export to svg as explained in another comment, open with inkscape and export to dwg.


It doesn't have export to svg... and I don't know what other comment you're referring to. :S


≥ Yes, but it is (as of this moment) an experimental feature. Add "?svg=1" to the end of the URL to enable this feature [0].

[0]: https://github.com/anvaka/city-roads/issues/4


Amazing! Thanks x1000000!


Should now work for all :)


Really great idea and nicely made! Congratulations! I'm considering making a poster out of it, with our home town. I think my wife would love to have it. Seeing it on the wall would probably make us less home-sick.

How complicated would it be to add the option of highlighting one or two streets? Something like, make the street line thicker or change its color.


Thank you! I've added a way to export maps to SVG file, which can be edited by an SVG editor, those editors also usually support adjusting thickness and changing colors of the roads. Would this work?


I was thinking about it. I saw, after I commented that you added an SVG export, but did not have time play with it. I'll definitely have a look. Thank you!


> Something went wrong. The error was:

> { "statusError": 504, "message": "Unexpected status code 504 when calling https://overpass.openstreetmap.ru/cgi/interpreter" }

And the referenced url 404s


Try a smaller city. This rendered almost immediately for me: https://anvaka.github.io/city-roads/?q=La%20Plata%2C%20Argen...


To fetch the roads I use overpass turbo API. They are sometimes slow and timeout and sometimes limit amount of requests that we can send. So I found three endpoints of overpass turbo and rotate between them: in case when one fails I go to the next one. If none was able to handle the request, I bail out and show the error.

That said, I also cached 3,000 cities with population over 100k citizens and try the cache first, before going to overpass. That may be the reason why it is fast in some cases and slow in others.

By the way if someone has more stable/fast overpass endpoints - I will be happy to add them to the list!


Try a smaller city. This rendered almost immediately for me

I tried Sandy Valley, Nevada. Doesn't get much smaller than that.

Unexpected status code 504 when calling https://overpass.openstreetmap.ru/cgi/interpreter


Now the site is not loading at all for me. Oops, there it goes. I think it could be overwhelmed.

I think it just does not have data on smaller towns and cities. I've tried several US smaller cities and nothing works. However, your link does. I can get San Diego and Irvine, CA. But I can't get Redlands or Yucaipa, CA. I can't get Polson, MT (nor Kalispell nor Helena).

Edit: Update - Finally got some data on Polson, MT.


Sorry it takes so long sometimes! I assume overpass (the back end that gives data) may experience higher loads which would affect response time! But glad it finally worked!


Amazing! Thank you so much for this. I am getting myself an A3 diagram of my hometown.


It's definitely missing a lot of roads in my city.

Compare it's view to Beaverton, Oregon: https://anvaka.github.io/city-roads/?q=Beaverton%2C%20OR&are...

With the Google Maps view: https://www.google.com/maps/@45.5029349,-122.8365195,13.75z

It's like most of the Cedar Hills neighborhood doesn't exist. It also drew a line for a power line where there is no road.


OpenStreetMap's definition of Beaverton is quite complicated: https://www.openstreetmap.org/relation/423111 It includes several cut-outs for neighborhoods (including Cedar Hills) and other features. I'd guess that the OSM mappers were trying to represent a particular legal definition of the Beaverton city limits. How accurate it is, I wouldn't know.

Perhaps in situations like this, "City Roads" might consider ignoring the cut-out enclaves and just using the mulipolygon's outer boundaries.

The power line showing up as a road is a mystery. If you can locate the corresponding feature on OSM you might want to investigate it. (There may in fact be a road or trail of some sort, though -- it's common for powerlines to have a track for maintenance vehicles.)


There's definitely a little bit of fuckery regarding Beaverton's borders.

My mailing address is in Beaverton, but OSM thinks it's Aloha. My zip code according to the post office is 97003, but some map software rejects it as non-existent, or forces a change to 97006.

OSM's Portland borders also definitely don't match what mailing addresses are there. I used to live in apartments off of NW 185th near US-26, which most people would call Beaverton, but my mailing address was Portland, but I was at least 4 miles from anywhere people would actually call Portland.

I wonder how common these confusing city limits are in other metro areas.


The boundary was initially imported from US Census Bureau data, which frequently does attempt to follow actual administrative boundaries.

The source data tends to not be incredibly accurate.


The ZIP Code 97003 took effect on 2014-07-01, when the ZIP Code 97006 was split [2].

ZIP Codes are not geographical entities and don't correspond to geographical extent; rather, they are a hybrid between a discrete number of finite delivery-points and an abstract way of capturing a postal delivery route. They are often abused as geographical entities, which the Census Bureau has tried to rectify with ZCTAs [1], but it's unclear whether most informal use of ZIP Codes is haphazard, or actually conforms to ZCTAs.

However, ZIP Codes directly map to one preferred place name designated by the USPS, and zero or more acceptable alternative place names. These are usually inspired by, but don't necessarily correspond to municipalities and political units that the lots in question belong under.

For both 97003 and 97006, the USPS recommended place name is "BEAVERTON", and other acceptable names are "ALOHA" and "HILLSBORO".

Beaverton's city limits are complicated [3][4]. The city has a map of annexations as well [5]. Cedar Hill was once supposed to be annexed. A court case about the proposed annexation of the Nike HQ resulted in these plans being put on hold [6].

[1] https://www.census.gov/geo/reference/zctas.html [2] https://about.usps.com/news/state-releases/or/2014/or_2014_0... [3] https://www.beavertonoregon.gov/DocumentCenter/View/9005/Cit... [4] https://www.beavertonoregon.gov/DocumentCenter/View/5554/Bea... [5] https://www.beavertonoregon.gov/DocumentCenter/View/843/Anne... [6] https://www.oregonlive.com/oregonianextra/2006/06/appellate_...


What OSM shows as matching the relation to the city is very strange. The boundary is so folded that I can't tell which parts are inside and which parts are very carefully excluded... If you look at other cities vs yours on OSM you'll see that it looks like most of Cedar Hills is excluded on OSM or rather the roads are their but it doesn't consider them part of the city.

Denver, CO: https://www.openstreetmap.org/relation/253750

Beaverton, Oregon: https://www.openstreetmap.org/relation/423111


It's interesting to see how some cities are spread out. For instance, Aleppo is pretty interesting in that it has clusters of compact streets growing out of the center.


Looks great - one observation, when I enter Kansas City I have to choose MO or KS. It would be great to be able to select a county or metro area.

I wonder if something similar was used to create the laser cut wood maps you can find on Etsy[0].

[0] https://www.etsy.com/listing/605571478/kansas-city-wooden-ma...


You should be able to enter counties - it may take a bit longer to download all the roads, sometimes it may take a while to download though and timeout...


That's an impressive work! It runs smoothly even for large cities.

I guess you cannot really fix it because it probably comes from the data you are using, but for Tokyo the default zoom is broken because a bunch of unrelated places is also displayed.

Do you think you could also include the railroads/subways? I think here it is a more relevant way of finding your path in the city rather than the roads and the result could be quite interesting.


My first instinction was to look at Tokyo as well, it's impressive to see.


Typed in 'Brisbane', an Australian city of 3 million, but the only result that came up was Brisbane, Santa Monica.

Any thoughts on international support? :)


I see that it is defined as `node` in osm: https://nominatim.openstreetmap.org/details.php?place_id=164...

We need `relationship` osm type to get the boundaries...

There is an ongoing discussion on the repository to give a better fallback: https://github.com/anvaka/city-roads/issues/7


I just did the same thing!


Wow this thing is fast!

I expected lag on my phone but it works great.


Yeah I was genuinely blown away by how fast this rendered every street in Chicago on mobile, a very side-street dense city.


thank you :)!


If you folks are enjoying this but want more flexibility, check out Mapbox - it lets you define fully custom styles for OpenStreetMap maps and download them as high res images or embed them in apps (basically this but more flexible and a bit harder to use). https://www.mapbox.com/


Nice work! Easy to use (and fast).

Reminds me of this print I still have on my wall called "All Streets Limited" by Ben Fry.


Thank you!


I did my city. Lots of streets (that are decades old) are not on there, including the street that my house is on (which has been there since at least 1970). Other streets cut out and then pick back up a half mile or so later. What happened to the road in between those two points?


It looks great, but is the rendering of the OSM data the main thing or am I overlooking a feature here?


from the GitHub: "beautiful art"

I think the main feature is buying the rendering as a coffee mug.


Lol

I hope it has more potential than art, though art in itself is very strong and inspirational thing!

For example, one could use this tool to debug missing areas in OSM. You could also use it as a source of large natural graphs to study network flow, deseas propgation, etc.

Finally it could also be used for educational purposes: you could show various graph algorithms on this data with something more realistic than abstract graphs :)


Huh, didn't find my hometown somehow. Dies this only work for cities over a certain size?


If you are able to find your town here https://nominatim.openstreetmap.org/ - and the osm type for the found place is "relationship" not node - it should work.

We are trying to find a fallback for `node` types here https://github.com/anvaka/city-roads/issues/7 - we basically don't have accurate city boundaries for nodes.


Did you compare to a regular old canvas doing path calls?

Or SVG?

Most web browsers these days should GPU accelerate line drawing, making the whole lot one single openGL/directX/vulkan api call.

If it doesn't perform equivalently, it's really a browser bug, and ought to be fixed.


Unless you queue up primitives for batch rendering, there is no chance that the canvas API is even remotely as fast as proper WebGL usage due to its design. You need to create a vertex buffer (at least somewhere under hood) and submit it in a single operation (at least under the hood) to get this kind of performance. Looping over lines on the CPU with immediate submission doesn't get you anywhere close.


No browser does immediate submission of canvas draw calls. They all appear synchronous, but the reality is they are all queued until the end of a browser main frame, or until your code does something silly like reading back a pixel.


Very nice, customisable colours for water and different land types would be great.


Weird edge case: there's a big gap in the middle of London where the City of London is. Technically the City of London is a seperate entity, but for most practical day to day purposes they are considered the same.


Export to something printable would be really neat. The export to PNG is cute but it's 2K wide, not useful for anything but potentially a desktop background.


Great project, a small thing you could add is a scale on some corner with just a line saying how much meters / kilometers it represents


I see an empty page when I enter my city (after it downloads it, I disabled uBlock but that didn't change anything) :(


Interesting! What's the city name?


Well, any city actually. I tried Warsaw, Berlin, New York.

I tried disabling ublock but with no changes.


Awesome tool. How did you choose which cities to support? The capital and largest city of my country isn't supported.


This is so cool! Doesn't find Cape Town, South Africa, which does show up on OpenStreetMap.org, though.


Really awesome! some weird quirks with the City search though. Couldn't find Cape Town, South Africa


Yeah saw that too, it takes a bit of fiddling to get the right search term, try:

https://anvaka.github.io/city-roads/?q=City%20of%20Cape%20To...


Apparently it can't load all of California, but other than that, this is really cool.


Locally it is limited by ram, video card capabilities. Remotely it depends on overpass turbo API being able to process huge request s. Which error do you see?


This is incredibly cool. Cheers.


Thank you !


My neighborhood was non-existant between the two cities that end on both sides of it.


It renders footways as roads so don't use this while driving. :D


Love it, keep going


Unable to export to png in Safari on iPhone xs


Can I play Pac-Man on it?


Very cool!


HAHAHA.. I searched for "New Delhi", India The system crashed. Makes sense after all Delhi is as big as Singapore.


I misread it as the website that tenders every single road within a city.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: