How to find the Polygons Intersection inside Apache Fuseki Server? - geospatial

I am using Apache Jena Fuseki Server for Storing Geo Coordinates of location. How to find out that if two polygons or two rectangles intersect each other inside Fuseki. Please share links related to it if possible. Thank you.
Hello...I am just updating question based on the below comments. Please suggest me regarding the problem I am facing. I have stored geocoordinates in WKT serialization format. When I execute below query
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://example.org/#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX spatial: <http://jena.apache.org/spatial#>
SELECT ?object
WHERE {
GRAPH <http://project/base/default> {
?subject geo:asWKT ?object .
} }
I get these below results.
object
1
"POLYGON((8.463699817657472 48.99872928913063,8.463887572288515 48.998644821906865,8.46399486064911 48.998764483764916,8.46425771713257 48.99865538031766,8.464375734329225 48.998746886450874,8.463919758796694 48.99893693711346,8.463699817657472 48.99872928913063))"
2
"POLYGON((8.463560342788698 48.99847940651206,8.463560342788698 48.99864834137738,8.46377491950989 48.99864834137738,8.46377491950989 48.99847940651206,8.463560342788698 48.99847940651206))"
3
"POLYGON((8.463447690010073 48.99835974396915,8.463447690010073 48.99849348443939,8.463646173477175 48.99849348443939,8.463646173477175 48.99835974396915,8.463447690010073 48.99835974396915))"
4
"POLYGON((8.463254570961 48.99821544463795,8.463254570961 48.99838438039854,8.463635444641115 48.99838438039854,8.463635444641115 48.99821544463795,8.463254570961 48.99821544463795))"
5
"POLYGON((8.463689088821413 48.99826823712468,8.463689088821413 48.99845477012966,8.46402168273926 48.99845477012966,8.46402168273926 48.99826823712468,8.463689088821413 48.99826823712468))"
6
"POLYGON((8.463892936706545 48.99843013373508,8.463892936706545 48.998588510344774,8.464316725730898 48.998588510344774,8.464316725730898 48.99843013373508,8.463892936706545 48.99843013373508))"
7
"POLYGON((8.463093638420107 48.99805354732974,8.463093638420107 48.998243600637835,8.463737368583681 48.998243600637835,8.463737368583681 48.99805354732974,8.463093638420107 48.99805354732974))"
8
"POLYGON((8.463619351387026 48.99797963751407,8.463619351387026 48.998180249615714,8.464118242263796 48.998180249615714,8.464118242263796 48.99797963751407,8.463619351387026 48.99797963751407))"
9
"POLYGON((8.464407920837404 48.998303432084754,8.464407920837404 48.99857443244431,8.46477270126343 48.99857443244431,8.46477270126343 48.998303432084754,8.464407920837404 48.998303432084754))"
10
"POLYGON((8.464225530624391 48.99806762537742,8.464225530624391 48.99839141937611,8.464820981025698 48.99839141937611,8.464820981025698 48.99806762537742,8.464225530624391 48.99806762537742))"
Then later I want to filter out these geo:WKT objects based on geo:intersection (Intersection or equals or contains methods). And I updated my query as below.
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://example.org/#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX spatial: <http://jena.apache.org/spatial#>
SELECT ?object
WHERE {
GRAPH <http://project/base/default> {
?subject geo:asWKT ?object .
?object geo:equals "POLYGON((8.463699817657472 48.99872928913063,8.463887572288515 48.998644821906865,8.46399486064911 48.998764483764916,8.46425771713257 48.99865538031766,8.464375734329225 48.998746886450874,8.463919758796694 48.99893693711346,8.463699817657472 48.99872928913063))"
} }
Which should result me atleast the coordinates of first geo object which really equals the POLYGON coordinates but I get empty results as shown in below image. Please suggest me where I am getting it wrong.

Related

is there a method to select all categories MeSH with sparql

i want to get data with sparql from Medical Subject Headings RDF
i try to do this code :
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX meshv: <http://id.nlm.nih.gov/mesh/vocab#>
PREFIX mesh: <http://id.nlm.nih.gov/mesh/>
PREFIX mesh2015: <http://id.nlm.nih.gov/mesh/2015/>
PREFIX mesh2016: <http://id.nlm.nih.gov/mesh/2016/>
PREFIX mesh2017: <http://id.nlm.nih.gov/mesh/2017/>
SELECT DISTINCT ?descriptor ?label
FROM <http://id.nlm.nih.gov/mesh>
WHERE {
mesh:D009369 meshv:treeNumber ?treeNum .
?childTreeNum meshv:parentTreeNumber+ ?treeNum .
?descriptor meshv:treeNumber ?childTreeNum .
?descriptor rdfs:label ?label .
}
ORDER BY ?label
this code return
descriptor label
mesh:D000182 ACTH Syndrome, Ectopic
mesh:D049913 ACTH-Secreting Pituitary Adenoma
mesh:D000008 Abdominal Neoplasms
but me i want to get from this page for example https://meshb.nlm.nih.gov/record/ui?ui=D000172 :
Musculoskeletal Diseases [C05]
Bone Diseases [C05.116]
Bone Diseases, Endocrine [C05.116.132]
Acromegaly [C05.116.132.082]
Congenital Hypothyroidism [C05.116.132.256]
.........
but i want to collect all data (code with label) from mesh, not only this example
I know I'm not answering your question, but you are missing the rdfs prefix in the beginning...
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
Paul

SPARQL DBpedia - Retrieve category information in any language by using labels

I have a problem, which I explain on following example:
I want to retrieve all information in any language on a category. I must use ?category as a label and the language labels en, as they are inputs in my program.
The query looks like this, but when I change the language I don't receive any information on the category. I know the problem lies in the dcterms:subject, because ?category returns http://dbpedia.org/resource/Category:Countries_in_Europe (see first example below).
For example to search for a category label in german you have to use http://de.dbpedia.org/resource/Kategorie:Staat_in_Europa (see second example below).
prefix dcterms: <http://purl.org/dc/terms/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?objectLabel WHERE {
?subject dcterms:subject ?category ; rdfs:label ?objectLabel
?category rdfs:label "Countries in Europe"#en .
FILTER (LANG(?objectLabel)='en')
}
Equivalent query in different language that doesn't work as example:
prefix dcterms: <http://purl.org/dc/terms/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?objectLabel WHERE {
?subject dcterms:subject ?category ; rdfs:label ?objectLabel
?category rdfs:label "Staat in Europa"#de .
FILTER (LANG(?objectLabel)='de')
}
Is there a similar or different way / method to solve the problem? Thanks in advance for any help.

How to obtain Bio2RDF resource using SPARQL query?

I am working with Bio2RDF biological database and would like to get resource URL for Novobiocin which is [http://bio2rdf.org/drugbank:DB01051 ] using SPARQL query.Using yasgui.org I selected http://drugbank.bio2rdf.org/sparql service and executed the following query:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT ?resource WHERE { ?resource dcterms:identifier "drugbank:DB01051"}
However, It did not retrieve the result. Could you tell me why it does not work, please ?

I want to get all "is dbo:wikiPageRedirects of" in dbpedia using sparql [duplicate]

This question already has answers here:
Why is dbpedia-owl:wikiPageRedirects not returning the full set of redirect links? (Sparql)
(2 answers)
Closed 7 years ago.
I wanted to get the "is dbo:wikiPageRedirects of" and use it as an alias to the label.
ex:
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 dbo: <http://dbpedia.org/ontology/>
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#>
SELECT *
WHERE {
FILTER (?uri = <http://dbpedia.org/resource/Benigno_Aquino_III>)
OPTIONAL{
?uri rdfs:label ?label .
FILTER( LANG(?label) = "" || LANGMATCHES(LANG(?label), "en") )
}
OPTIONAL
{
?uri dbo:birthDate ?birthDate .
}
OPTIONAL
{
?uri rdfs:label "Benigno Aquino III"#en ;
dbo:wikiPageRedirects ?redirectsTo .
}
}
what I get is a blank wikiPageRedirects, But when i use http://dbpedia.org/resource/PNOY i get http://dbpedia.org/resource/Benigno_Aquino_III as redirectsTo. I want to do the opposite.
The relation is "dbo:wikiPageRedirects of" and not "dbo:wikiPageRedirects". In this case, it means that http://dbpedia.org/resource/Benigno_Aquino_III lists the resources which have a connection of the sort
?u dbo:wikiPageRedirects http://dbpedia.org/resource/Benigno_Aquino_III
you should use
?redirectsTo dbo:wikiPageRedirects ?uri .

sparql query - triple

I am a biology trying to understand the meaning of a triple from this SPARQL query. If "a" is a triple, what are the resources for subject, object and predicate in this sample query?
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX efo: <http://www.ebi.ac.uk/efo/>
PREFIX atlas: <http://rdf.ebi.ac.uk/resource/atlas/>
PREFIX atlasterms: <http://rdf.ebi.ac.uk/terms/atlas/>
SELECT DISTINCT ?experiment ?description WHERE
{?experiment
a atlasterms:Experiment ;
dcterms:description ?description ;
atlasterms:hasAssay
[atlasterms:hasSample
[atlasterms:hasSampleCharacteristic
[ atlasterms:propertyType ?propertyType ;
atlasterms:propertyValue ?propertyValue]
]
]
filter regex (?description, "diabetes", "i")
}
I appreciate your help?
Thanks,
AD
?experiment
a atlasterms:Experiment ;
is the same as
?experiment a atlasterms:Experiment ;
is the same as
?experiment rdf:type atlasterms:Experiment ;
so the form in the query is just a whitespace rearrangement and using the built-in abbreviation "a" for property rdf:type.
See http://www.sparql.org/query-validator.html for an online formatter of SPARQL queries.
A simpler query is:
SELECT DISTINCT ?experiment ?description
WHERE
{ ?experiment rdf:type atlasterms:Experiment .
?experiment dcterms:description ?description
FILTER regex(?description, "diabetes", "i")
}
because
SELECT DISTINCT ?experiment ?description
means that the ?propertyType/?propertyValue part is not affecting the outcome.

Resources