This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How to get feature data from OSM?

0

Hi there,

I imported the OSM tile layer into Javascript (leaflet), and can see it visually. But how do I access the actual data of the layer? It's vector data, made of points, lines, and polygons, right? How can I access the feature data for some part of the map with Javascript, like as json?

Ex: Get the data for the polylines/polygons making up the streets/blocks of a town.

Thank you

asked 17 Jan '18, 00:03

noncomp's gravatar image

noncomp
21226
accept rate: 0%

edited 17 Jan '18, 00:15

1

If I understand you well, you mean you want to access, for a certain area of the map, the underlying osm data that the OSM renderer used to create the tiles ?

(17 Jan '18, 02:12) edvac

Yes, e.g. if it displays an area with some streets and blocks from OSM, I want to be able to access the vector feature data describing those streets and blocks. Thank you, help is much appreciated!

(17 Jan '18, 02:38) noncomp

One Answer:

2

You can query the OSM data with Overpass.

There seems to be a framework to do that from Leaflet. Another method is to build the query and parse the result yourself in Javascript.

This page lists some websites that combine Overpass and Leaflet

answered 17 Jan '18, 04:09

escada's gravatar image

escada
19.0k16166302
accept rate: 21%

edited 17 Jan '18, 11:09

The link you attached to "framework" doesn't link to a leaflet plugin, have you got a direct link? Thank you!

(17 Jan '18, 06:32) noncomp
1

i've corrected the link. sorry for the inconvenience

(17 Jan '18, 11:09) escada

Source code available on GitHub .