How to use simple vocabulary line with GeoSPARQL:sfWithin and polygon? - sparql

RDF:
prefix ex: <http://www.example.org/>
prefix geo: <http://www.opengis.net/ont/geosparql#>
ex:b7 a sf:Line ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> LINESTRING(55.3 -160.5,55.3 -160.5)^^geo:wktLiteral .
SPARQL query:
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix geof: <http://www.opengis.net/def/function/geosparql/>
prefix sf: <http://www.opengis.net/ont/sf#>
prefix ex: <http://www.example.org/>
prefix ogis: <http://www.opengis.net/def/uom/OGC/1.0/>
select * where {
?a a sf:Line .
FILTER (geo:sfWithin(?a, "<http://www.opengis.net/def/crs/EPSG/0/4326> POLYGON((50 -170, 50 -140, 60 -140, 60 -170))"^^geo:wktLiteral))
}
In open-source edition of Virtuoso this results in the error:
Virtuoso 42000 Error RDFGE: RDF box with a geometry RDF type and a non-geometry content
Does the line also need to be declared as a geo:Geometry?
Edit: sf:Line is a subclass of geo:Geometry, so I assumed it could be used in the same fashion.

Related

SPARQL query: show result for individuals without some attributes, and sum two of the attributes

I have to make this SPARQL query on protege:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX sw:<http://www.semanticweb.org/lorep/ontologies/2022/0/untitled-ontology-16#>
SELECT ?Name ?Surname ?test ?written ?oral ?Course
WHERE {
?Candidates sw:take_parts ?Course;
sw:Name ?Name;
sw:Surname ?Surname;
sw:test ?test;
sw:written ?written;
sw:oral ?oral;
}
Now I have some candidates that took only the test without taking written and oral so when I execute the query they does not show. How can I make everyone visible?
And then how could i sum the values from written and oral? I tried with BIND(?written+?oral AS ?total) but it doesn't seem to work

Yasgui SPARQL Query search for FOAF name doesn't work

I am using the Jamendo Yasgui SPARQL query to search for artist names. It works like this:
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {?a a mo:MusicArtist ;foaf:name ?name;}
If I want to find a specific name like below, it does not work. Why?
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * WHERE {?a a mo:MusicArtist ;foaf:name "Carton";}
The data exists as you can see in the RDF/XML:
<foaf:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Carton</foaf:name>
Because SPARQL syntax was built to look like Turtle syntax (and vice versa), it's often helpful to look at your data in Turtle when building SPARQL queries. This RDF/XML --
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE rdf:RDF><rdf:RDF xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:ns1="http://purl.org/ontology/mo/" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
<ns1:MusicArtist rdf:about="http://dbtune.org/jamendo/artist/5655">
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>
<owl:sameAs rdf:resource="http://zitgist.com/music/artist/b8b40a3c-91c0-413b-a4f9-194ef0c7151a"/>
<foaf:based_near rdf:resource="http://sws.geonames.org/2802361/"/>
<foaf:homepage rdf:resource="http://cartonpate.com"/>
<foaf:img rdf:resource="http://img.jamendo.com/artists/c/carton.jpg"/>
<foaf:made rdf:resource="http://dbtune.org/jamendo/record/4957"/>
<foaf:name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Carton</foaf:name>
</ns1:MusicArtist>
</rdf:RDF>
-- says the same thing as this Turtle --
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
PREFIX owl: <http://www.w3.org/2002/07/owl#> .
PREFIX foaf: <http://xmlns.com/foaf/0.1/> .
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://dbtune.org/jamendo/artist/5655>
a <http://purl.org/ontology/mo/MusicArtist>,
rdfs:Resource ;
owl:sameAs <http://zitgist.com/music/artist/b8b40a3c-91c0-413b-a4f9-194ef0c7151a> ;
foaf:based_near <http://sws.geonames.org/2802361/> ;
foaf:homepage <http://cartonpate.com> ;
foaf:img <http://img.jamendo.com/artists/c/carton.jpg> ;
foaf:made <http://dbtune.org/jamendo/record/4957> ;
foaf:name "Carton"^^xsd:string .
-- so your SPARQL query must be (modulo whitespaces, each of which may be reduced to a single space) --
PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT * WHERE { ?a a mo:MusicArtist ;
foaf:name "Carton"^^xsd:string }

sparql - How to remove Xml from query result

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX base: <http://www.cs7is1.com/ireland-school-county#>
SELECT ((COUNT(?school))/?a AS ?density)
WHERE {
?school base:inCounty base:DUBLIN.
base:area ?a
}
GROUP BY ?a
I run this query, query is fine but I am getting a result like this
"0.47776812"^^<http://www.w3.org/2001/XMLSchema#float>
I want to remove the XML content, I tried to bind it didn't work

Different order of results in DBpedia through SNORQL vs. SERVICE query

I am trying to retrieve some data about movies from DBpedia. This is my query:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX onto: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
{{SELECT *
WHERE {
SERVICE<http://dbpedia.org/sparql>{
?movie dcterms:subject <http://dbpedia.org/resource/Category:American_films> ;
a onto:Film ;
rdfs:label ?title ;
dbpedia2:gross ?revenue .
?movie onto:starring ?actorUri .
?actorUri rdfs:label ?actor .
OPTIONAL {
?movie onto:imdbId ?imdbId .
}
BIND(xsd:integer(?revenue) as ?intRevenue) .
FILTER ((datatype(?revenue) = 'http://dbpedia.org/datatype/usDollar') && (LANGMATCHES(LANG(?title), 'en')) && (LANGMATCHES(LANG(?actor), 'en'))) .
}
}
}}
ORDER BY DESC (?intRevenue)
LIMIT 40000
OFFSET 0
Running this query on http://dbpedia.org/snorql/ (without the SERVICE keyword) returns the correct result. However, doing so from a third party triplestore doesn't yield the same order (ex: Hobbit and Lord of the Rings are missing).
What do I need to change in the query to get identical results?
The best way to overcome this specific limitation is to have your own DBpedia mirror, on which you can set your own limits (including none), and which you can then use as either your primary or remote data store and/or query engine.
(ObDisclaimer: OpenLink Software provides the public DBpedia SPARQL endpoint, produces Virtuoso and the DBpedia Mirror AMI, and employs me.)

SPARQL query against DBPedia to get all property-value of the item

I am a novice in Semantic Web and I would like to retrieve all property-value pairs of "apple" from DBPedia using SPARQL query. Below I have written the query in http://dbpedia.org/sparql editor, but it returns no any results.Could you tell me where I make a mistake, please?
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix dbo: <http://dbpedia.org/ontology/>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix dbp: <http://dbpedia.org/property/>
prefix dct: <http://purl.org/dc/terms/>
select * where {<http://http://dbpedia.org/page/Apple> ?property ?value}
You wrote http:// twice. Also, the correct URI for the query is /resource/, not /page/.
Working query:
select * where {<http://dbpedia.org/resource/Apple> ?property ?value}
Keep in mind this will give you information about the fruit, not the company.
I am giving you the query which will give you information about Apple Company rather than apple Fruit.
PREFIX dbprop: <http://dbpedia.org/property/>
PREFIX db: <http://dbpedia.org/resource/>
SELECT ?property, ?value WHERE {db:Apple_Inc ?property ?value}