There's a spatial table in Postgis with polygon geometry, a column with id and a column with the needed value. There are several users who input points in a website

The coordinates of these points fall within a certain polygon in this table, the website needs the values from the polygon table.

In other words, the input would be lat, lon. And the output would be a 5 letter value reference.

Is it possible for Geoserver to return this value reference? and if so how to do it? Or is it better to build a function on the database?

  • A simple WFS query would do this, what have you tried so far?
    – Ian Turton
    Commented Mar 6, 2017 at 17:00
  • @iant select value into ref from schema.table where ST_Contains(schema.table.geom, ST_Transform(ST_SetSRID(ST_MakePoint(p_lon, p_lat),4326),27700)); return ref but doesnt work in geoserver
    – Luffydude
    Commented Mar 6, 2017 at 17:13

1 Answer 1


The WFS reference should provide what you need. You can run a WFS request on a layer and GeoServer will reply all data that fulfills the query, including the columns that you have exposed in your database (unless you have chosen to hide them when you created the GeoServer layer).

For the coordinates you may use the BBOX parameter, i.e.:


You can not define a null-sized filter, however. That means you can not ask a feature at an exact (lat,lon) coordinate. But you can query a small box around it, e.g. from (lat-0.01,lon-0.01) to (lat+0.01,lon+0.01).

The result will be in GML by default. If you are not familiar with it, I suggest you use another outputformat such as csv by adding &outputFormat=csv at the end of the request.

As a last note, be careful about the WFS version. For WFS 1.0.0 the BBOX parameter uses lon1,lat1,lon2,lat2 but in WFS 2.0.0 this is lat1,lon1,lat2,lon2.


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.