Count points in polygons with WFS or WPS

239 Views Asked by At

I'm having 2 separate layers in geoserver. One containing polygons and other one contains points. How can I count the number of points within each polygon using wfs or wps requests?

QGIS describing the exact functionality I'm asking.

I tried using vec:InclusionFeatureCollection WPS function but it only returns attributes from the first feature collection so I can't count them grouped by polygons:

<wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
  <ows:Identifier>vec:InclusionFeatureCollection</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
        <ows:Identifier>first</ows:Identifier>
            <wps:Reference mimeType="text/xml; subtype=wfs-collection/1.0" xlink:href="http://geoserver/wfs" method="POST">
                <wps:Body>
                    <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2">
                        <wfs:Query typeName="osm:events"/>
                    </wfs:GetFeature>
                </wps:Body>
        </wps:Reference>
    </wps:Input>
    <wps:Input>
        <ows:Identifier>second</ows:Identifier>
            <wps:Reference mimeType="text/xml; subtype=wfs-collection/1.0" xlink:href="http://geoserver/wfs" method="POST">
                <wps:Body>
                    <wfs:GetFeature service="WFS" version="1.0.0" outputFormat="GML2">
                        <wfs:Query typeName="osm:administrative_4"/>
                    </wfs:GetFeature>
             </wps:Body>
        </wps:Reference>
    </wps:Input>
  </wps:DataInputs>
  <wps:ResponseForm>
    <wps:RawDataOutput mimeType="text/xml; subtype=wfs-collection/1.0">
      <ows:Identifier>result</ows:Identifier>
    </wps:RawDataOutput>
  </wps:ResponseForm>
</wps:Execute>
0

There are 0 best solutions below