# GeoSPARQL use geof:within

**URL:** <https://community.stardog.com/t/geosparql-use-geof-within/979>\
**Category:** Support\
**Created:** [May 2, 2018, 6:59am UTC](https://community.stardog.com/t/geosparql-use-geof-within/979 "2018-05-02T06:59:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanguy](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@Tanguy](https://community.stardog.com/u/Tanguy)\
**Post date:** [May 2, 2018, 6:59am UTC](https://community.stardog.com/t/geosparql-use-geof-within/979/1 "2018-05-02T06:59:13Z")

</div>

I want to use geoSPARQL functions, then I have followed the example from the manual:

> @prefix db: [http://data/#](http://data/#) .  
> @prefix geo: [http://www.opengis.net/ont/geosparql#](http://www.opengis.net/ont/geosparql#) .  
> @prefix rdfs: [http://www.w3.org/2000/01/rdf-schema#](http://www.w3.org/2000/01/rdf-schema#) .
> 
> db:redHouse a geo:Feature ;  
> rdfs:label "Red House" ;  
> geo:hasGeometry db:redHouseGeo .
> 
> db:redHouseGeo a geo:Geometry ;  
> geo:asWKT "Point(0 0)"^^geo:wktLiteral .
> 
> db:whiteHouse a geo:Feature ;  
> rdfs:label "White House" ;  
> geo:hasGeometry db:whiteHouseGeo .
> 
> db:whiteHouseGeo a geo:Geometry ;  
> geo:asWKT "Point(0 0)"^^geo:wktLiteral .

then I try to request:

> PREFIX geo: [http://www.opengis.net/ont/geosparql#](http://www.opengis.net/ont/geosparql#)  
> PREFIX geof: [http://www.opengis.net/def/function/geosparql/](http://www.opengis.net/def/function/geosparql/)
> 
> SELECT DISTINCT  
> ?g  
> WHERE {  
> ?g geo:asWKT ?gWKT .  
> FILTER geof:within(?g, "ENVELOPE(-100, 100, 100, -100)"^^geo:wktLiteral ) .  
> }

And I have no results.

But when I try:

> PREFIX geo: [http://www.opengis.net/ont/geosparql#](http://www.opengis.net/ont/geosparql#)  
> PREFIX geof: [http://www.opengis.net/def/function/geosparql/](http://www.opengis.net/def/function/geosparql/)
> 
> SELECT DISTINCT  
> ?g  
> WHERE {  
> ?g geo:asWKT ?gWKT .  
> }

I have a result:  
---------------------| g |------------------------------  
| [http://data/redHouseGeo](http://data/redHouseGeo) |  
| [http://data/whiteHouseGeo](http://data/whiteHouseGeo) |

My problem is similar to this one: [https://community.stardog.com/t/geosparql-not-working/797](https://community.stardog.com/t/geosparql-not-working/797), but I have enable spatial indexing when creating my database.  
Can you help me to understand what is wrong ?

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [May 2, 2018, 10:33am UTC](https://community.stardog.com/t/geosparql-use-geof-within/979/2 "2018-05-02T10:33:09Z")

</div>

I think the use on ENVELOPE may require JTS to be installed. I’d include a link but I’m on my phone but a quick search of the Stardog docs and you should find instructions.

---

<div class="post-metadata">

**Author:** ![Tanguy](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@Tanguy](https://community.stardog.com/u/Tanguy)\
**Post date:** [May 2, 2018, 10:50am UTC](https://community.stardog.com/t/geosparql-use-geof-within/979/3 "2018-05-02T10:50:07Z")

</div>

Thanks, but it is because I was using the community version, now it’s work.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [May 16, 2018, 10:50am UTC](https://community.stardog.com/t/geosparql-use-geof-within/979/4 "2018-05-16T10:50:09Z")

</div>

Closed on May 16, 2018, 10:50am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
