0

I am working using spatial filter Dwithin for WFS. I have worked using a simple filter using to show no of earthquake data for the year 2020 in GeoJSON format from the given WFS:- https://emidius.mi.ingv.it/services/italy/wfs/?service=wfs&version=2.0.0&request=GetFeature&typeNames=italy:CPTI_current&outputFormat=application/json&FILTER=%3CFilter%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3EYear%3C/PropertyName%3E%3CLiteral%3E2020%3C/Literal%3E%3C/PropertyIsEqualTo%3E%3C/Filter%3E

However, I could get the value of no of earthquake points at a distance 500m from coordinates 14.964, 37.696 in GeoJSON format.The output is all GeoJSON data being selected which is not true. The link with spatial filter (that I have used for the provided WFS) is as shown:- https://emidius.mi.ingv.it/services/italy/wfs/?service=wfs&version=2.0.0&request=GetFeature&typeNames=italy:CPTI_current&outputFormat=application/json&%20FILTER=%3C%20Filter%3E%3CWithin%3E%3CPropertyName%3Egeometry%3C/PropertyName%3E%3CPoint%3E%3Ccoordinates%3E14.964,%2037.696%3C/%20coordinates%20%3E%3C/Point%3E%3CDistance%20units=%27m%27%3E5000%3C/Distance%3E%3C/Within%3E%3C/Filter%3E

4
  • You mention a WMS layer, but provide no link to one? Please clarify. Also, spatial operations on WMS-layers usually don't work?
    – Erik
    Commented Jan 26, 2022 at 11:00
  • I was provided with end point for get feature request: emidius.mi.ingv.it/services/italy/wfs/… modified it get feature request and try to apply spatial filter encoding but that's not working.
    – Walker
    Commented Jan 26, 2022 at 11:03
  • That's clearly a WFS service. Please edit your question accordingly.
    – user30184
    Commented Jan 26, 2022 at 11:17
  • Sry I have changed it.
    – Walker
    Commented Jan 26, 2022 at 11:21

1 Answer 1

3

There are multiple problems with your filter:

  1. The space before FILTER prevents the server parsing and using it
  2. You spelled DWithin wrong (Within is a different filter entirely)
  3. You are using the wrong geometry name (it's geom)
  4. Your unit needs to be meters
  5. Your point should not have a comma separating the coordinates.
  6. Probably a bunch of other stuff

So I switched to using CQL

https://emidius.mi.ingv.it/services/italy/wfs/?service=wfs&version=2.0.0&request=GetFeature&typeNames=italy:CPTI_current&outputFormat=application/json&CQL_FILTER=dwithin(geom,%20POINT(14.964%2037.696),%20500,%20meters)

which works but says there are no earthquakes with in 5 km of your point, but does find 46 if I flip the axis order of your point to give a dwithin(geom, POINT(37.696 14.964), 5, kilometers) and a final URL of:

https://emidius.mi.ingv.it/services/italy/wfs/?service=wfs&version=2.0.0&request=GetFeature&typeNames=italy:CPTI_current&outputFormat=application/json&CQL_FILTER=dwithin(geom,%20POINT(37.696%2014.964),%205,%20kilometers)

Or if you prefer the OGC representation:

<?xml version="1.0" encoding="UTF-8"?>                                                                                  
<ogc:Filter xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc">
  <ogc:DWithin>                                                                                                         
    <ogc:PropertyName>geom</ogc:PropertyName>                                                                           
    <gml:Point>                                                                                                         
      <gml:coord>                                                                                                       
        <gml:X>37.696</gml:X>                                                                                           
        <gml:Y>14.964</gml:Y>                                                                                           
      </gml:coord>                                                                                                      
    </gml:Point>                                                                                                        
    <ogc:Distance units="kilometers">5.0</ogc:Distance>                                                                 
  </ogc:DWithin>                                                                                                        
</ogc:Filter>                                                                                                           
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.