Created
October 23, 2020 18:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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