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

I've just discovered this new Sophox API.

I would to get all cities (place=city) in the Arab World. I assume that it would be much easier to query for this using Wikidata than filtering the global dump.

The arab countries have the following Wikidata IDs: Q79 Q262 Q1049 Q796 Q1028 Q851 Q805 Q858 Q1045 Q948 Q878 Q810 Q1016 Q1176995 Q822 Q842 Q817 Q1025 Q846 Q398 Q977 Q970

Is this possible and how would it look like? Thanks in advance.

asked 03 Jul '18, 20:14

Nehaj's gravatar image

Nehaj
31558
accept rate: 0%

updated my reply with an example

(28 Nov '18, 18:58) nyuriks

Nehaj, updating my reply. Sophox is back up. Here's a sample query, but unfortunately it is very slow - I suspect it needs some federated query optimizations:

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>

SELECT * WHERE {
  VALUES ?countries { wd:Q79 wd:Q262 wd:Q1049 wd:Q796 wd:Q1028 wd:Q851 wd:Q805 wd:Q858 wd:Q1045 wd:Q948 wd:Q878 wd:Q810 wd:Q1016 wd:Q1176995 wd:Q822 wd:Q842 wd:Q817 wd:Q1025 wd:Q846 wd:Q398 wd:Q977 wd:Q970 }

  ?osmid osmt:place "city" ;
         osmt:wikidata ?wd .

  SERVICE <https://query.wikidata.org/sparql> {
    ?wd wdt:P17 ?countries .
  }

} limit 10
permanent link

answered 05 Jul '18, 07:26

nyuriks's gravatar image

nyuriks
71226
accept rate: 0%

edited 28 Nov '18, 18:56

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:

×147
×19
×1

question asked: 03 Jul '18, 20:14

question was seen: 1,939 times

last updated: 28 Nov '18, 18:58

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