Looking for Scotland

Querying Wikidata on Scottish topics can be awkward, because it tends not to be represented as a Country / sovereign state (wdt:P17) in item properties but more often (at best) as an administrative territory (wdt:P131). Because of this, identifying monuments, buildings, companies, organisations as specific to Scotland can be tortuous.

At various times, I have tried

  • Filtering by map location, for items with a wdt:P625 which can be parsed to coordinates, and an ugly broad filter applied:
    FILTER (?lat > 54.63) FILTER (?lat < 60.87) FILTER (?long > -8.8) FILTER (?long < 0.71).

  • Trawling for a location (the item's own wdt:P625, or Headquarters wdt:P159, or Administrative Location wdt:P131) then filtering by latitude / longitude.

  • Moving downwards from a subquery to identify Local Councils (wdt:P31 wd:Q15060255) then entries for places within each Council area. This works ok for towns and "administered" things.

  • Moving upwards from an item through its Administrative Location wdt:P131 hoping to reach Scotland (wd:Q22), either directly or mediated through the Administrative Location's own Administrative Location. However rural locations tend to be several layers down, so searches don't avoid query timeout.

When seeking to develop a lasting topic query, I have tended to work around the problem by ensuring items carry an Administrative Location wdt:P131 property of Scotland (wd:Q22), using Quickstatements. I am uneasy about changing data for query convenience, but where it is a matter of, for example, football leagues or companies, their incorporation would have been under Scots Law, so the data property is justifiable.

Trying to achieve a look-don't-touch alternative logic has led to a Frankenstein logic, trying to move upward through administrative layers until either of two "scotmarks" (wd:Q22 or wd:Q15060255) is encountered:

{?org wdt:P131 ?scotmarks.} 

    UNION {?org wdt:P131 ?orgloc1. ?orgloc1 wdt:P31/wdt:P131 ?scotmarks.} 

UNION {?org wdt:P159 ?orgpl. {{?orgpl wdt:P31/wdt:P131 ?scotmarks.} .} 

                             UNION {?orgpl wdt:P131 ?orgl2. {{?orgl2 wdt:P31/wdt:P131 ?scotmarks} }}}.

This seems horribly ugly, but - at least for a query such as organisations in Scotland with Mastodon accounts - is returning the same items as an eye-check on Scotland in a world map query.

It would be great to have something tidier though.


Author: admin

Mastodon account where these were first posted: link