NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

5
1

I'd like to list the names of every streets in a given city (from OSM data). How can I do that?

I've tried with nominatim a query like: http://nominatim.openstreetmap.org/search?q=residentials%20in%20delft,netherlands

But it returns an empty result (while if I look for "pubs", it works fine). Using the details.php, I see that nominatim can list them: http://open.mapquestapi.com/nominatim/v1/details.php?place_id=7227120

I'm working around using Xapi and a bounding box, but that works kind of ok only if the city is not surrounded too closely by other cities. Example of such a query: http://azure.openstreetmap.org/xapi/api/0.6/*[highway=residential][bbox=2.8634295463562,49.2131958007812,2.936068534807,49.2601203918457]

Can anyone suggest me a way to get it working via nominatim?

asked 12 Feb '11, 11:29

%C3%89ric%20Piel's gravatar image

Éric Piel
116458
accept rate: 0%


If you want to do it regularly for lots of cities this is the way:

  1. download osmosis (and perhaps osmembrane which is a beta GUI for osmosis)
  2. download your country extract netherlands.osm.pbf (~430MB)
  3. create a polygon file parseable by osmois (see osm2polygon)
  4. run osmosis with the polygon and extract all ways that have the tags name=* and highway=residential
    1. way-key name,highway
    2. tag filter reject-node, reject-relation

Then just filter out all the names in the resulting OSM xml file match all lines containing k="name" v=" this can be done in many ways. Parsing Sweden (~70MB) with osmosis takes about 16 seconds on a 4 year old desktop machine..

This is my osmosis line without poly file

osmosis-0.38/bin/osmosis --read-pbf file=sweden.osm.pbf  \
--bounding-box left=17.8 right=18.16 top=59.45 bottom=59.27 \
--way-key keyList=highway \
--way-key keyList=name \
--tag-filter reject-nodes \
--tag-filter reject-relations \
--write-xml Stockholm-names.osm

Then I run:

sed -n 's/.*k="name" v="//;T;s|"/>||;p' Stockholm-names.osm |sort -u

Creating a Polygon file

With Josm I created the a .osm file like this,

<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='JOSM'>
  <bounds minlat='59.323463999999994' minlon='18.0798161' maxlat='59.323715799999995' maxlon='18.0805349' origin='CGImap 0.0.2' />
  <bounds minlat='59.323463999999994' minlon='18.0798161' maxlat='59.323715799999995' maxlon='18.0805349' origin='OpenStreetMap server' />
  <node id='-28' visible='true' lat='59.30925658' lon='18.044743' />
  <node id='-26' visible='true' lat='59.31157127' lon='18.035956' />
  <node id='-24' visible='true' lat='59.31533231' lon='18.025752' />
  <node id='-22' visible='true' lat='59.31779123' lon='18.026035' />
  <node id='-20' visible='true' lat='59.31938219' lon='18.028019' />
  <node id='-18' visible='true' lat='59.32024996' lon='18.037940' />
  <node id='-16' visible='true' lat='59.32256391' lon='18.048995' />
  <node id='-14' visible='true' lat='59.32184082' lon='18.068552' />
  <node id='-12' visible='true' lat='59.31865904' lon='18.086693' />
  <node id='-10' visible='true' lat='59.31692339' lon='18.108802' />
  <node id='-8' visible='true' lat='59.31157127' lon='18.103133' />
  <node id='-6' visible='true' lat='59.30621830' lon='18.098881' />
  <node id='-4' visible='true' lat='59.30260096' lon='18.077056' />
  <node id='-2' visible='true' lat='59.30274566' lon='18.068552' />
  <node id='-1' visible='true' lat='59.30549486' lon='18.058065' />
  <way id='-3' action='modify' visible='true'>
    <nd ref='-1' />
    <nd ref='-2' />
    <nd ref='-4' />
    <nd ref='-6' />
    <nd ref='-8' />
    <nd ref='-10' />
    <nd ref='-12' />
    <nd ref='-14' />
    <nd ref='-16' />
    <nd ref='-18' />
    <nd ref='-20' />
    <nd ref='-22' />
    <nd ref='-24' />
    <nd ref='-26' />
    <nd ref='-28' />
    <nd ref='-1' />
    <tag k='polygon_file' v='sodermalm' />
    <tag k='polygon_id' v='1' />
  </way>
</osm>

With perl osm2poly.pl <sodermalm_poly.osm>sodermalm.poly I got this:

sodermalm
1
   1.805807E+01   5.930549E+01
   1.806855E+01   5.930275E+01
   1.807706E+01   5.930260E+01
   1.809888E+01   5.930622E+01
   1.810313E+01   5.931157E+01
   1.810880E+01   5.931692E+01
   1.808669E+01   5.931866E+01
   1.806855E+01   5.932184E+01
   1.804900E+01   5.932256E+01
   1.803794E+01   5.932025E+01
   1.802802E+01   5.931938E+01
   1.802604E+01   5.931779E+01
   1.802575E+01   5.931533E+01
   1.803596E+01   5.931157E+01
   1.804474E+01   5.930926E+01
   1.805807E+01   5.930549E+01
END
END

Then I ran osmosis:

osmosis-0.38/bin/osmosis --read-pbf file=sweden.osm.pbf  \
-bounding-polygon file=osmosis-0.38/sodermalm.poly \
--way-key keyList=highway \
--way-key keyList=name \
--tag-filter reject-nodes \
--tag-filter reject-relations \
--write-xml Stockholm-names.osm
permanent link

answered 17 Feb '11, 13:57

emj's gravatar image

emj
2.0k123547
accept rate: 15%

edited 17 Feb '11, 14:27

I've been gathering poly files for cities at https://github.com/JamesChevalier/cities The method that I go through to create the poly files is in the readme file (displayed at the bottom of the page).

(24 Aug '13, 03:04) JamesChevalier

Nominatim is designed to be a geocoding and reverse geocoding system rather than a general method of downloading data from OpenStreetMap and as such only a limited number of 'special' phrases work - normally restricted to points of interest. That said there will shortly be a downloadable version of the nominatim data set available which you could filter yourself for this information. Please watch for anouncements on the geocoding mailing list.

In the mean time you can download a suitable OSM file (either from xapi, or a planet extract or even the full planet file) and filter it using the bounding-polygon option of Osmosis. You may be able to download the polygon from OSM, in other cases you will have to draw it yourself.

permanent link

answered 15 Feb '11, 09:32

twain's gravatar image

twain
2.4k2538
accept rate: 40%

edited 15 Feb '11, 09:33

You mention 'You may be able to download the polygon from OSM' ... Where (when they exist) are those available?

(24 Jan '14, 18:25) JamesChevalier

You should also take a look at http://maposmatic.org/ , which does pretty much what you are looking for and allows you to download either a rendered version or the raw data. They explain how they did it in the "about" page, and the tool they wrote is available. It requires that you have a local installation of OSM tools and database.

permanent link

answered 15 Feb '11, 15:02

Vincent%20de%20Phily's gravatar image

Vincent de P... ♦
17.3k18152249
accept rate: 19%

edited 15 Feb '11, 15:09

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×689
×219
×147
×142

question asked: 12 Feb '11, 11:29

question was seen: 38,342 times

last updated: 24 Jan '14, 18:25

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum