I'm trying to make a buffer around a geometry (point/s,linestring,etc) using WFS queries without luck. This is what I've been doing:

     <ogc:Function name="buffer">
         <gml:coordinates cs="," ts=""> x,y </gml:coordinates>        
     ...           </ogc:Filter>

I read I could do it using Dwithin, but is it possible with the buffer?

  • 1
    Do you want to select features which are within distance of 300 meters around the geometry you give as an input, or is your aim to get from the service a buffered geometry? The first is possible to do with WFS, for the latter you will need WPS. Give some more information, please. – user30184 Jun 1 '14 at 20:17
  • I want to select features. For example if I intersects $geometry with a point it works, but when I add the buffer to the point I got an empty response. – sbrz73 Jun 1 '14 at 21:24
  • The right thing to use is DWithin. Some examples can be found from Mapserver documentation mapserver.org/ogc/filter_encoding.html The syntax of the filters may not be totally valid but they are quite readable and the document is therefore good reading. – user30184 Jun 1 '14 at 21:49
  • Thanks, using DWithin works properly. Anyway I'd like to know how I should use a buffer (filter functions), or somewhere where I can read about it – sbrz73 Jun 1 '14 at 23:39
  • If you write the buffer filter correctly then the WFS server will send you the selected features with the buffer applied to them. Buffer is not made for selecting the features. However, you may be able to use it also for that indirectly by writing a filter which takes a reference geometry and applies buffer for it and finally puts this buffered geometry into Intersects filter. If it works, the result is the same than by using DWithin directly. Geoserver documents has some info about filter functions docs.geoserver.org/stable/en/user/filter/… – user30184 Jun 2 '14 at 4:24

The answer is to use DWithin function instead of buffer.

Usage example:

  </gml:Point><Distance units='m'>10000</Distance></DWithin></Filter>

The filter selects features which are closer than "Distance" to the reference geometry. In the example distance unit is in meters and geometry is obviously using degrees but some WFS servers do not handle mixed units correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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