0

I'm trying to get a list of all of the landmark buildings in NYC / Manhattan. The problem I'm getting is when the building has multiple owners - my query only returns the name of one of the owners, and I need them all. Example is the Chrysler Building - I'm only seeing "Signa Holding" when I should get "Signa Holding", "Tishman Speyer", and "Abu Dhabi Investment Council".

Another question - I'm trying to get the building's architectural height (wdt:P2048/wd:Q24192182) - how do I add that as an optional parameter?

My query:

SELECT DISTINCT ?skyscraperLabel ?skyscraperDescription ?inception ?link ?coord ?lat ?lon ?postalCode ?ownedBy ?ownedByLabel ?floorsAboveGround ?floorsBelowGround ?geonamesID
WHERE
{
  ?skyscraper wdt:P1435* wd:Q19825927.  # NYC Landmark
  ?skyscraper wdt:P131* wd:Q11299.  # Located in Manhattan
  OPTIONAL {?skyscraper wdt:P571 ?inception}
  OPTIONAL {?skyscraper wdt:P856 ?link.}     # official website
  OPTIONAL {?skyscraper wdt:P625 ?coord .} # geographic coord
  OPTIONAL {
    ?skyscraper p:P625 ?statement.
    ?statement psv:P625 ?node.
    ?node wikibase:geoLatitude ?lat.
    ?node wikibase:geoLongitude ?lon.
   }
  OPTIONAL {?skyscraper wdt:P281 ?postalCode.}     # Postal Code
  OPTIONAL {
    ?skyscraper wdt:P127 ?ownedBy.
    ?ownedBy rdfs:label ?ownedByLabel filter (lang(?ownedByLabel) = "en").
  }     # Owner
  OPTIONAL {?skyscraper wdt:P1101 ?floorsAboveGround.}     # Floors above ground
  OPTIONAL {?skyscraper wdt:P1139 ?floorsBelowGround.}     # Floors below ground
  OPTIONAL {?skyscraper wdt:P1566 ?geonamesID.}     # GeoNamesID
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
John
  • 1,167
  • 1
  • 16
  • 33
  • 1
    1) preferred rank vs normal rank, see https://www.wikidata.org/wiki/Help:Ranking -> solution: use the statements instead of the direct triples 2) just add another OPTIONAL clause with the triple pattern or what does not work in case you already tried it? – UninformedUser Feb 13 '22 at 20:09
  • 1
    so you have to do this: `?skyscraper p:P127/ps:P127 ?ownedBy.` - clearly, this will generate multiple rows for the same landmark, to avoid this you have to use an aggregate function `group_concat` and also `group_by` all other projected variables – UninformedUser Feb 13 '22 at 20:14
  • 1
    for the height: `OPTIONAL {?skyscraper p:P2048 [ps:P2048 ?height ; pq:P1013 wd:Q24192182] }` – UninformedUser Feb 13 '22 at 20:32

0 Answers0