Query by Infrastruktur, Wikidata entries without P18 linked to OSM elements that have wikimedia_commons=*
PREFIX osmm: <https://www.openstreetmap.org/meta/>
PREFIX osmt: <https://wiki.openstreetmap.org/wiki/Key:>
select ?wd ?wdLabel ?countryLabel ?s ?commons ?sitelink WITH {
select ?wd ?wdLabel ?countryLabel ?s ?commons
where {
SERVICE <https://sophox.org/sparql> {
select ?s ?wd ?commons
where {
?s osmt:wikimedia_commons ?commons ;
osmt:wikidata ?wd .
}
}
FILTER NOT EXISTS { ?wd wdt:P18 [] . }
} } as %i
WHERE
{
INCLUDE %i
OPTIONAL {?wd wdt:P17 ?country.}
OPTIONAL { ?url schema:about ?wd ;
schema:isPartOf <https://commons.wikimedia.org/> ;
schema:name ?sitelink .
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!