1

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%


One Answer:
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 ♦
73.3k866641137
accept rate: 24%

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:

×591
×197
×42
×6

question asked: 25 Apr '19, 16:32

question was seen: 542 times

last updated: 25 Apr '19, 20:15

powered by OSQA