Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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