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

Hi,

I have a spreadsheet where in column A are listed some italian cities, is there a formula that can retrieve the relation ID of that city automatically? To do it I'm actually going to nominatin, searching the city, select first result and copy the relation ID. Is there a way to automate this work?

example:

COLUMN A COLUMN B

Milano 44915

L'Aquila 41842

Nissoria 39323

Thanks

asked 25 Apr '19, 16:32

volo86's gravatar image

volo86
36224
accept rate: 0%


This could, on the Unix command line, be achieved by a combination of using curl to send a request to Nominatim followed by processing the JSON result with the jq utility, for example:

curl -s "https://nominatim.openstreetmap.org/search?q=Milano&format=json" | 
  jq '.[] | select(.class=="place") | select(.type=="city") | 
    select(.osm_type=="relation").osm_id'

You might have to toy with the jq expression a bit to achive the best result. Of course, you can do the same in a programming language of your choice - "request this URL", "decode JSON", "find objects that are cities", "extract their osm_id" - this should be possible with most common scripting languages.

permanent link

answered 25 Apr '19, 20:15

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

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
×236
×55
×8

question asked: 25 Apr '19, 16:32

question was seen: 2,869 times

last updated: 25 Apr '19, 20:15

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