Search notes:

R package: SPARQL

Example

The following example queries the endpoint of Wikidata for the fountains of Zurich:
library(SPARQL)
  
endPointWikiData <- 'https://query.wikidata.org/sparql';

query <- '
  select
       ?fountain
       ?statement
       ?img 
       ?coord
  where
  {
    ?fountain      p:P528   ?statement    .  # https://www.wikidata.org/wiki/Property:P528 / catalog name of an object, use with qualifier P972
    ?statement     pq:P972                   # https://www.wikidata.org/wiki/Property:P972 / catalog for the item, or, as a qualifier of P528 – catalog for which the "catalog code" is valid
                             wd:Q53629101 .  # https://www.wikidata.org/wiki/Q53629101     / The fountain data set maitained by City of Zurich drinking water supply
    ?fountain      wdt:P18  ?img          .  # https://www.wikidata.org/wiki/Property:P18  / Image of relevant illustration of the subject;
    ?fountain      wdt:P625 ?coord        .  # https://www.wikidata.org/wiki/Property:P625 / Coordinate location
  }
';

res <- SPARQL(endPointWikiData, query);

print(res$results$fountain );
print(res$results$statement);
print(res$results$img      );
print(res$results$coord    );
Github repository about-r, path: /packages/SPARQL/fountains-of-Zurich.R

See also

SPARQL
R packages

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745508702, '3.145.36.157', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/packages/SPARQL/index(72): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78