Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Probably right: OSM needs layers, or even a more sweeping re-architecture to allow better versioning, moderation, better tooling, and easier understanding of the data.

I have a hobby site about railways [0] I'm picking up again after a decade of inactivity. I wanted to display a route map of each railway, with clickable stations and the route highlighted.

I can not work out how to do that. OSM has the route and station data (there and in Open Railway Map [1]). I expected to find a layer called 'Railways' with sub-layers, one for each railway, and I could export the data and highlight it on another map.

Instead I have raster tiles, and no way to highlight the railway I'm talking about. I know the data must be there somewhere but how on earth do I get it?

[0] https://www.narrow-gauge.co.uk [1] https://www.openrailwaymap.org/



The type of data you want for routes is probably in KMZ format. I took a few minutes looking around openrailwaymap and their wiki but nothing immediately obvious stood out.

https://catalog.data.gov/dataset/railroad-kmz

A brief google search came back with this; I haven't inspected the data or even tried to use it to see what it contains, but the page description indicates it may not be exact routes you are looking for-but it's a start. Implementing the data is a bit more work in order to display route maps, something like the previously mentioned MapBox does this very interactively.

My email address is in the profile, feel free to shoot over an email if you'd like some help with it. Depending on the complexity, I can probably devote a few cycles this weekend to show you a one-off map with railway routes, and show you how it's done.


Is KMZ really still the best way to go?


Good question.

I'm only a hobbyist with GIS, so I can't really say or speak to how practical of a format KML/KMZ are in production.

But that's a really good question.


I work in GIS.

KML/KMZ is decently useful as an interchange format and simple rendering but almost all web GIS software has better support for GeoJSON. It’s richer and easier to work with.

I’ve never worked on a GIS system that used KML/KMZ in prod for rendering. It’s usually shapefiles, PostGIS Geometry, ESRI’s proprietary GDB feature, WKB/WKT or GeoJSON on the backend being served up to clients.

I have used it as a lightweight way to deliver simple data in the past though for use cases where there was no proper client renderer (we would just tell the end user to download google earth and open up the file)


Thanks for the offer, I got 75% through writing you an email and finally managed to get some data exported via https://overpass-turbo.eu/, so I'll work on that for now. Thanks though!


In some sense there is a layer, features related to railways will all have a railway tag (or be listed as a member of one of those features). There's some description here:

https://wiki.openstreetmap.org/wiki/Railways

In the sense of being easy to retrieve I guess it isn't a layer. Global railway data will be pretty huge, so Overpass-API may not work out if that is what you want. In that case, the strategy is to grab a planet file (a snapshot of the db) and filter it locally:

http://osmcode.org/osmium-tool/manual.html#filtering-by-tags

And then you probably have to translate the resulting data into a format that you would use for your map.

As to why you have to do that work instead of just pulling layers, it comes down to the core data model being focused on editing and there being many different end use cases (making it difficult to anticipate and serve each one).


OSM is essentially a database of points and lines, each with a (loosely defined) soup of tags attached to it. Highly flexible (annoyingly so, if you've got a single focus area) and not in a "layer" format.


Investigate Overpass and in particular Overpass Turbo.

And really, any strict layering system in OSM would quickly just fall apart into debates of exactly what belonged in each layer. The range of detail captured by OpenStreetMap users in different areas is really far too nuanced to work crammed into coarse, crude "layer" classifications.


How can that be the case? Even with a range of detail, the points on a map have to represent one of a fairly limited selection of types. Even if you keep it high level like "buildings", "roads", etc. it's still a massive improvement over having no layers whatsoever.


> the points on a map have to represent one of a fairly limited selection of types

Absolutely not. Not only is the selection of types huge and full of shades of grey, but an element can be tagged as things from multiple different categories at once (and this is a wonderful feature). Take a browse of the OpenStreetMap wiki sometime. OpenStreetMap data is far richer than a layer model could cope with.

However, let's not confuse this with an editor having a layers-like interface feature to help the user focus on a particular subset of the data. JOSM for instance does this very successfully with the "filters" tool, which I use heavily.


In OSM objects have zero or more tags, a set of key/values (with both being strings). That's all. With that, the OSM community has come up with lots of ways to classify and tag things.

e.g. the railway nerds have very detailed ways to tag railway infastructure: https://wiki.openstreetmap.org/wiki/OpenRailwayMap/Tagging


If the data is in OpenMapTiles, which are vector files from OSM data, you may have more success styling it in the browser.

https://openmaptiles.org/


I'm currently doing something very similar for my school project and it's been quite a journey, the OSM ecosystem sure isn't simple.

My current solution is based on OpenMapTiles and uses their stack for creating, and subsequently rendering, vector tiles. First, I obtain an extract of OSM data via the Overpass API. Then I convert it from XML to protobuf, as it's a much more efficient format. Afterwards I import it into a PostGIS database using imposm3 and define some SQL functions that transform that data. Then I generate some vector tile definition from the OMT format into tm2source format. After that I finally generate the vector tiles in mbtiles format using tilelive, server them as GeoJSON using tileserver-gl and style them using maputnik and mapbox-gl styles.

There seems to be some bug with imposm3 and relations, because I can't get them to import. Or I'm just not doing it right.


Wow that is complicated! Thanks for sharing, it's good to know how time consuming this could be if I take it further.

It sounds like Overpass is the way to get the data I need - once I figure out how to reference it in Overpass (network/relation details).


You might be interested in this article from Alessandro, the guy who makes Spatialite: https://www.gaia-gis.it/fossil/spatialite-tools/wiki?name=gr...

It talks about the errors in Open Street Map data, and the consequences of that for railway routing.


Check out the overpass <https://overpass-turbo.eu>. You should be able to query for the data you are looking for.


Here’s something similar I’ve built: https://stereo.lu/charely


Thanks, that was fascinating to read (even allowing for my poor french). That is the kind of data I'm looking to get out.




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

Search: