Skip to content

Instantly share code, notes, and snippets.

@loleg
Created October 23, 2020 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loleg/9130ee35b151c0d776af834a30b3802d to your computer and use it in GitHub Desktop.
Save loleg/9130ee35b151c0d776af834a30b3802d to your computer and use it in GitHub Desktop.
An example of how to connect to the LINDAS service with the R package for SPARQL
library(SPARQL)
endpoint <- "https://lindas.admin.ch/query"
rdf_query <- "
PREFIX : <http://voc.zazuko.com/zack#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX gont: <https://gont.ch/>
SELECT DISTINCT ?Haltestelle WHERE
{ GRAPH <https://linked.opendata.swiss/graph/FOT/didok> {
?sub gont:municipality ?municipality .
?sub ?pred ?obj .
}
?didok rdfs:label ?Haltestelle
} LIMIT 100
"
myOpts <- curlOptions(sslversion=1.2)
res <- SPARQL(endpoint, rdf_query, curl_args=myOpts)
df <- res$results
df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment