Regarding Linked Geo Data dataset

69 views
Skip to first unread message

R

unread,
Feb 22, 2016, 2:41:16 PM2/22/16
to Linked Geo Data
Dear All,

I need the Linked Geo Data dataset used by the authors of VLDB 2014 paper "An effective encoding scheme for spatial RDF" for some of my work. I looked at the datasets available for download at  http://downloads.linkedgeodata.org/releases, however, the queries proposed in the paper "An effective encoding scheme for spatial RDF" do not work on the datasets available here: http://downloads.linkedgeodata.org/releases. If possible, can you point me the Linked Geo Dataset which they have used in their work?

R

unread,
Feb 27, 2016, 2:28:16 AM2/27/16
to Linked Geo Data
Gentle reminder

Claus Stadler

unread,
Mar 3, 2016, 12:32:13 AM3/3/16
to linked-...@googlegroups.com, raviya...@gmail.com
Hi,

In the paper at http://www.vldb.org/pvldb/vol7/p1271-liagouris.pdf
the authors do not use exact SPARQL queries, instead they present a sketch of the essential graph patterns and filters - but no namespaces, and the ogc:asWkt does not appear there.

So this is a working corresponding query for their [LGD.J2]
The other queries have to be converted analogously.

PREFIX lgdo: <http://linkedgeodata.org/ontology/>
PREFIX ogc: <http://www.opengis.net/ont/geosparql#>
PREFIX geom: <http://geovocab.org/geometry#>
SELECT ?s1 ?s2 ?l1 ?l2 Where {
  ?s1
    a lgdo:Police ;
    rdfs:label ?l1 ;
    geom:geometry [ ogc:asWKT ?w1 ] .

  ?s2
    a lgdo:Police ;
    rdfs:label ?l2 ;
    geom:geometry [ ogc:asWKT ?w2 ] .

  FILTER(bif:st_within(?w1, ?w2, 0.01))
  FILTER(strstarts(str(?w1), "POINT"))
  FILTER(strstarts(str(?w2), "POINT"))
} LIMIT 10

The last two filters by "POINT" are there to restrict the query to point-point comparison as stated in the paper, because ?w1 and ?w2 may as well be linestrings.
Alternatively, this can also be accomplished by adding the triple pattern ?s a <http://linkedgeodata.org/meta/Node>

(click the link to run it)
http://linkedgeodata.org/sparql?default-graph-uri=http%3A%2F%2Flinkedgeodata.org&qtxt=PREFIX+lgdo%3A+%3Chttp%3A%2F%2Flinkedgeodata.org%2Fontology%2F%3E%0D%0APREFIX+ogc%3A+%3Chttp%3A%2F%2Fwww.opengis.net%2Font%2Fgeosparql%23%3E%0D%0APREFIX+geom%3A+%3Chttp%3A%2F%2Fgeovocab.org%2Fgeometry%23%3E%0D%0ASELECT+%3Fs1+%3Fs2+%3Fl1+%3Fl2+Where+{%0D%0A++%3Fs1%0D%0A++++a+lgdo%3APolice+%3B%0D%0A++++rdfs%3Alabel+%3Fl1+%3B%0D%0A++++geom%3Ageometry+[+ogc%3AasWKT+%3Fw1+]+.%0D%0A%0D%0A++%3Fs2%0D%0A++++a+lgdo%3APolice+%3B%0D%0A++++rdfs%3Alabel+%3Fl2+%3B%0D%0A++++geom%3Ageometry+[+ogc%3AasWKT+%3Fw2+]+.%0D%0A%0D%0A++FILTER%2 8 bif%3Ast_within%28%3Fw1%2C+%3Fw2%2C+0.01%29%29%0D%0A++FILTER%28strstarts%28str%28%3Fw1%29%2C+%22POINT%22%29%29%0D%0A++FILTER%28strstarts%28str%28%3Fw2%29%2C+%22POINT%22%29%29%0D%0A}+LIMIT+10&format=text%2Fhtml&timeout=0&debug=on

Hope this helps and best regards,
Claus
--
You received this message because you are subscribed to the Google Groups "Linked Geo Data" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linked-geo-da...@googlegroups.com.
To post to this group, send email to linked-...@googlegroups.com.
Visit this group at https://groups.google.com/group/linked-geo-data.
For more options, visit https://groups.google.com/d/optout.

-- 
Dipl. Inf. Claus Stadler
Department of Computer Science, University of Leipzig
Research Group: http://aksw.org/
Workpage & WebID: http://aksw.org/ClausStadler
Phone: +49 341 97-32260

Ravi Yadav

unread,
Mar 3, 2016, 5:53:59 AM3/3/16
to Claus Stadler, linked-...@googlegroups.com
Dear Claus,

Thank you very much for the wonderful explanation.

I am afraid, LGD. J4 is a polygon-polygon query and I could not find "polygons" in LGD dataset, therefore can you please guide me as to how would one execute this query on LGD dataset:

LGD.J4* (polygon-polygon) 
Select ?s1 ?s2 Where ?s1 type park . ?s1 hasGeometry ?g1 . ?s2 type park . ?s2 hasGeometry ?g2 . Filter DISTANCE(?g1,?g2) < “0.05”

Claus Stadler

unread,
Mar 3, 2016, 8:36:51 AM3/3/16
to Ravi Yadav, linked-...@googlegroups.com
Hi,

So unfortunately the way osmosis works, there are only linestrings in LGD, which however can be converted to polygons.
This has to be decided on the tags, e.g. Parks are most likely to be interpreted as polygons - but the transformation can be done directly with sparql:
Basically, you just have to replace "LINESTRING" with "POLYGON(" and append a closing ")" at the end. They meta:Node / meta:Way triple can be used to filter
by ways and nodes that imply linestring and point geometries, respectively.


PREFIX geom: <http://geovocab.org/geometry#>
PREFIX lgdo: <http://linkedgeodata.org/ontology/>
PREFIX meta: <http://linkedgeodata.org/meta/>
PREFIX ogc: <http://www.opengis.net/ont/geosparql#>
SELECT ?s ?w2 WHERE {
  ?s
    a lgdo:Park ;
    a meta:Way ;
    geom:geometry [ ogc:asWKT ?w ]
  BIND(
    bif:st_geomFromText(
      concat(
        replace(str(?w), "LINESTRING", "POLYGON("),
        ")"
      )) AS ?w2)
}
LIMIT 10

http://linkedgeodata.org/sparql?default-graph-uri=http%3A%2F%2Flinkedgeodata.org&qtxt=PREFIX+geom%3A+%3Chttp%3A%2F%2Fgeovocab.org%2Fgeometry%23%3E%0D%0APREFIX+lgdo%3A+%3Chttp%3A%2F%2Flinkedgeodata.org%2Fontology%2F%3E%0D%0APREFIX+meta%3A+%3Chttp%3A%2F%2Flinkedgeodata.org%2Fmeta%2F%3E%0D%0APREFIX+ogc%3A+%3Chttp%3A%2F%2Fwww.opengis.net%2Font%2Fgeosparql%23%3E%0D%0ASELECT+%3Fs+%3Fw2+WHERE+{%0D%0A++%3Fs%0D%0A++++a+lgdo%3APark+%3B%0D%0A++++a+meta%3AWay+%3B%0D%0A++++geom%3Ageometry+[+ogc%3AasWKT+%3Fw+]%0D%0A++BIND%28%0D%0A++++bif%3Ast_geomFromText%28%0D%0A + +++++concat%28%0D%0A++++++++replace%28str%28%3Fw%29%2C+%22LINESTRING%22%2C+%22POLYGON%28%22%29%2C%0D%0A++++++++%22%29%22%0D%0A++++++%29%29+AS+%3Fw2%29%0D%0A}%0D%0ALIMIT+10&format=text%2Fhtml&timeout=0&debug=on

If the distance on linestrings in unsuitable for your use case, you can either run sparql update queries on the dataset in order to replace the linestrings with polygons using the idea of the query above, or or you can create queries that do a rough first check using e.g. bif:st_intersects on the linestring - which will use the spatial index - and then a subsequent precise filter on the geometries converted to polygons.

Virtuoso's bif:st_distance (see http://docs.openlinksw.com/virtuoso/fn_rdf_geo_add.html for geo functions) apparently only works for points, but as a workaround
bif:st_intersects (I accidently used bif:st_within in my prior mail) can be used, which accepts a tolerance as the last argument: http://docs.openlinksw.com/virtuoso/fn_st_within.html


Best regards,
Claus

Ravi Yadav

unread,
Mar 9, 2016, 9:05:30 PM3/9/16
to Claus Stadler, linked-...@googlegroups.com
Dear Claus,

Thanks a lot for all the clarifications :)

Is it possible to obtain all tags (e.g. Parks) which are also polygons?

Ravi Yadav

unread,
Mar 10, 2016, 6:47:06 AM3/10/16
to Claus Stadler, linked-...@googlegroups.com
Dear Claus,

I have one more question. It will be very kind of you if you can help with this a bit:

I tried to insert the first polygon of the SPARQL query you gave (http://linkedgeodata.org/sparql?default-graph-uri=http%3A%2F%2Flinkedgeodata.org&qtxt=PREFIX+geom%3A+%3Chttp%3A%2F%2Fgeovocab.org%2Fgeometry%23%3E%0D%0APREFIX+lgdo%3A+%3Chttp%3A%2F%2Flinkedgeodata.org%2Fontology%2F%3E%0D%0APREFIX+meta%3A+%3Chttp%3A%2F%2Flinkedgeodata.org%2Fmeta%2F%3E%0D%0APREFIX+ogc%3A+%3Chttp%3A%2F%2Fwww.opengis.net%2Font%2Fgeosparql%23%3E%0D%0ASELECT+%3Fs+%3Fw2+WHERE+{%0D%0A++%3Fs%0D%0A++++a+lgdo%3APark+%3B%0D%0A++++a+meta%3AWay+%3B%0D%0A++++geom%3Ageometry+[+ogc%3AasWKT+%3Fw+]%0D%0A++BIND%28%0D%0A++++bif%3Ast_geomFromText%28%0D%0A + +++++concat%28%0D%0A++++++++replace%28str%28%3Fw%29%2C+%22LINESTRING%22%2C+%22POLYGON%28%22%29%2C%0D%0A++++++++%22%29%22%0D%0A++++++%29%29+AS+%3Fw2%29%0D%0A}%0D%0ALIMIT+10&format=text%2Fhtml&timeout=0&debug=on) in Postgis.

The corresponding polygon of the first result tuple being:
POLYGON((-5.8335446 43.3655635,-5.8336337 43.3655207,-5.8349218 43.3673341,-5.8345197 43.3674013,-5.8336182 43.3660938,-5.8335037 43.365924,-5.8334505 43.3658461,-5.8334702 43.3657311,-5.8335446 43.3655635))

However, upon insertion of the above polygon (which is the first result tuple), I am getting "invalid geometry" error in postgis. The exact statements executed in Postgis being:

CREATE TABLE my_table(               
  key1 serial not null,
  geom geometry(Geometry,4326),
  CONSTRAINT my_table_pkey PRIMARY KEY (key1)
)
WITH (
  OIDS=FALSE
);

INSERT INTO my_table(geom)  VALUES( ST_GeomFromText('POLYGON(-5.8335446 43.3655635,-5.8336337 43.3655207,-5.8349218 43.3673341,-5.8345197 43.3674013,-5.8336182 43.3660938,-5.8335037 43.365924,-5.8334505 43.3658461,-5.8334702 43.3657311,-5.8335446 43.3655635)', 4326));
ERROR:  parse error - invalid geometry

If possible, can you please help me understand as to where am I going wrong.

Ravi Yadav

unread,
Mar 13, 2016, 9:41:30 AM3/13/16
to Claus Stadler, linked-...@googlegroups.com
Gentle reminder.
Reply all
Reply to author
Forward
0 new messages