-
I am very new to SPARQL-Anything. My situation is similar to "Return a list of coordinates #517." I want to extract Roman provinces' geometries from GeoJSON. PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX for: <https://dkglab.github.io/ns/for/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX pno: <http://linked.data.gov.au/def/placenames/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
CONSTRUCT {
?Provincia a pno:Place ;
pno:hasPlaceName ?Provincia_wiki ;
pno:hasPlaceName ?provincia_alter_name ;
dcterms:identifier ?provincia_wiki_uri ;
dcterms:identifier ?pleiades_uri ;
a geo:Feature ;
geo:hasGeometry ?geometry .
?geometry geo:asGeoJSON ?geoJSON .
}
WHERE {
SERVICE <x-sparql-anything:> {
fx:properties fx:csv.headers "true" .
?row xyz:Provincia_wiki ?Provincia_wiki ;
xyz:provincia_wiki_uri ?provincia_wiki_uri ;
xyz:pleiades_uri ?pleiades_uri ;
xyz:provincia_alter_name ?provincia_alter_name .
BIND(STR(?Provincia_wiki) AS ?id)
BIND(fx:entity(for:, "Provincia_wiki/", ?id) AS ?Provincia)
}
SERVICE <x-sparql-anything:location=data/roman-provinces/Spain-Late-Antique-Provinces.geojson> {
fx:properties fx:media-type "application/json" .
?feature xyz:properties/xyz:Name ?provinceName ;
xyz:geometry ?geometryObj .
?geometryObj xyz:type ?type ;
xyz:coordinates ?coordinates .
BIND(STR(?type) AS ?typeStr)
BIND(STR(?coordinates) AS ?coordinatesStr)
BIND(CONCAT('{"type":"', ?typeStr, '","coordinates":', ?coordinatesStr, '}') AS ?geoJSONString)
BIND(STRDT(?geoJSONString, geo:geoJSONLiteral) AS ?geoJSON)
BIND(?geometryObj AS ?geometry)
BIND(?provinceName AS ?provincia_alter_name)
Here is a snippet of my GeoJSON file: {
"type": "FeatureCollection",
"name": "Spain Late Antique Provinces",
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features": [
{
"type": "Feature",
"properties": {
"id": null,
"Name": "Baetica"
},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
-7.299580642427583,
37.197226518805316
],
[
-7.360031300336245,
37.30364166312544
],
[
-7.430280864706607,
37.379240316182226
],
[
-7.381240000000616,
37.680459999999577
],
[
-7.405520000000251,
37.859169999999722
],
[
-7.444509999999355,
38.001280000000399
],
[
-7.443170000000464,
38.13311000000067
],
[
-7.32496,
38.36391
], The query returns this: <https://dkglab.github.io/ns/for/Provincia_wiki/Hispania_Tarraconensis>
rdf:type geo:Feature , pno:Place ;
pno:hasPlaceName "Tarraconensis" , "Hispania_Tarraconensis" ;
dcterms:identifier "https://pleiades.stoa.org/places/981551" , "https://www.wikidata.org/entity/Q216791" ;
geo:hasGeometry [ geo:asGeoJSON "{\"type\":\"MultiPolygon\",\"coordinates\":_:/features/_3/geometry/coordinates}"^^geo:geoJSONLiteral ] .
<https://dkglab.github.io/ns/for/Provincia_wiki/Hispania_Baetica>
rdf:type geo:Feature , pno:Place ;
pno:hasPlaceName "Baetica" , "Hispania_Baetica" ;
dcterms:identifier "https://pleiades.stoa.org/places/862" , "https://www.wikidata.org/entity/Q219415" ;
geo:hasGeometry [ geo:asGeoJSON "{\"type\":\"MultiPolygon\",\"coordinates\":_:/features/_1/geometry/coordinates}"^^geo:geoJSONLiteral ] .
@enridaga commented here #517 (comment) that "you get the blank node because that is what the variables capture." How do I extract coordinates? I have also tried variations of
This approach did not work. I would appreciate any help I can get. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Welcome, @ylan1. I've prepared a small example of how to extract coordinates here: https://github.com/SPARQL-Anything/sandbox/tree/main/issue523 Does it help? |
Beta Was this translation helpful? Give feedback.
Welcome, @ylan1. I've prepared a small example of how to extract coordinates here: https://github.com/SPARQL-Anything/sandbox/tree/main/issue523
Does it help?