query-11128ce6ec363b007314cc0ea16f34f6

rq turtle/ttl

Map of PM20 companies by headquarters locationper Wikidata query (uses country, if headquarters location is unknown; incudes other organizations)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Map{"hide":"?geo"}
select ?image ?item ?itemLabel ?locationLabel ?viewer ?geo
where {

  #
  # company items (directly linked)
  ?statement ps:P4293 ?pm20Id .
  filter(strstarts(?pm20Id, 'co/'))
  ?item p:P4293 ?statement .
  filter (not exists {
      ?statement pq:P4390 [] .
    })
  # with country
  ?item wdt:P17 ?country .
  optional {
    ?item wdt:P159 ?headquarters .
  }
  bind(coalesce(?headquarters, ?country) as ?location)
  #
  # restrict to items with online accessible articles
  ?item p:P4293/pq:P5592 ?workCount .
  filter(?workCount > 0)
  # geo coordinates for location
  ?location wdt:P625 ?geo .
  # optional image
  optional { ?item wdt:P18 ?image . }
  # viewer link
  bind(uri(concat('https://pm20.zbw.eu/dfgview/', ?pm20Id)) as ?viewer)
  # add labels
  service wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en, de, fr, es, nl, pl, ru". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?country") v8("?geo"):::projected v6("?headquarters") v9("?image"):::projected v4("?item"):::projected v7("?location") v3("?pm20Id") v2("?statement") v10("?viewer"):::projected v1("?workCount") a1((" ")) a2((" ")) c14(["#91;AUTO_LANGUAGE#93;,en, de, fr, es, nl, pl, ru"]):::literal c12(["bd:serviceParam"]):::iri f0[["?workCount > '0^^xsd:integer'"]] f0 --> v1 f1[["not "]] subgraph f1e0["Exists Clause"] e0v1 --"p:qualifier/P4390"--> e0a1 e0v1("?statement"):::projected e0a1((" ")):::projected end f1--EXISTS--> f1e0 f1 --> v2 f1 --> c2 f1 --> a1 v2 --"p:qualifier/P4390"--> a1 f2[["starts-with(?pm20Id,'co/')"]] f2 --> v3 v2 --"p:statement/P4293"--> v3 v4 --"p:P4293"--> v2 v4 --"p:direct/P17"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P159".-> v6 end bind3[/"?headquarters?country"/] v6 --o bind3 v5 --o bind3 bind3 --as--o v7 v4 --"p:P4293"--> a2 a2 --"p:qualifier/P5592"--> v1 v7 --"p:direct/P625"--> v8 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P18".-> v9 end bind4[/"concat('https://pm20.zbw.eu/dfgview/',?pm20Id)"/] v3 --o bind4 bind4 --as--o v10 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end