I am trying to construct a WFS request. I want to determine if a certain point is within a polygon. The point coordinates I want to send via the WFS request. The polygon is saved as a layer on my GeoServer. How does a WFS request like this look like.

My request looks like this, but I am getting an error:


The error says:

error on line 4 at column 160: xmlParseCharRef: invalid xmlChar value 16
  • Sorry, I answered before reading thoroughly your question. CQL_FILTER is usable with Geoserver but no other WFS server brand supports it so be careful if you plan to make an interoperable application. The main error is that the filter name is "Intersects", not "Intersect". I will edit my answer to show cql_filter option.
    – user30184
    Jun 2 '14 at 12:15

You can check within which polygon, if any, your point is by using Contains filter.

 <wfs:GetFeature service="WFS" version="1.0.0"
      <wfs:Query typeName="topp:states">
              <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">

If you want to use http GET it gets quite ugly:


GeoServer supports also CQL_FILTER vendor parameter. The previous point-in-polygon query could as well use the Intersects filter and the result will be the same as with Intersects


I recommend you to install GeoServer on your own computer. The user interface has rather many query and filter examples in the Demo - Demo requests section. Requests and filters appear in a text box and you can not only execute them but also edit them before which makes it easy for you to make and test your own requests.

  • Thanks for your answer. It works great. Also thanks for hint to the Geoserver demo request section. Never saw that before. I will check it out.
    – ustroetz
    Jun 2 '14 at 12:18

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.