[GIS] GeoJSON from OpenStreetMap with bike routes of a city only

geojsonopenstreetmap

How can I get (if it's possible) a GeoJSON from OpenStreetMap with bike routes of a city only?

I have to say that I'm pretty new with the all the map/geo language. But as a developer I'm experimenting with routes for a project and I wondering if this request it's possible.

I see that http://www.opencyclemap.org/ that exactly this but for the whole world, but I don't understand how are they doing it. Although I know that the offer tile services. But what I want to do if have the data so I can manipulate it.

Best Answer

There are two broad ways to do this - one is to piggyback on someone else's infrastructure. For instance, the overpass turbo api has a query already baked in to get cycle routes and this can be exported as geojson (see "load" tab). This is great for one-off queries and where you have a small amount of data, but you are reliant on the generosity of others so you need to bear this in mind morally and from a practical point of view (there is nothing stopping them turning off the server after all). The overpass API is just one of many similar services, including pre-built shapefiles etc, but in my opinion it is a good one to use.

The alternative is to create your own infrastructure. This is not a small undertaking, and basically involves replicating the main OSM database (or subset of) and creating your own images. There are a large number of guides (e.g. here) to do this and I can't possibly do the subject justice here, suffice to say that it is generally quite hard and will require a reasonable level of technical expertise. You also need to work out the difference between map tiles and vector data (geojson) and which you want to serve.

You could also "buy" in the tiles from a 3rd party supplier (e.g. Mapbox) and then just keep a database of cycle routes to serve as vector data. That would probably be simpler, but still involves syncing databases etc. Something like Osmosis could be used but there are many alternatives.

There are literally hundreds of different ways this question could be answered so I suggest you are a bit more specific about what exactly you want to do.

Related Question