3

I'm trying to retrive data from a WFS service using a polygon for a filter.

Working URL:

https://sosgeo.artdata.slu.se/geoserver/SOS/ows?service=wfs&version=2.0.0&request=GetFeature&typeName=SOS:SpeciesObservations&outputFormat=application/json&count=10

The polygon I want to filter by: Polygon ((760130 7090468, 759931 7090075, 760594 7090169, 760130 7090468)) CRS is EPSG:3006

My attempt:

https://sosgeo.artdata.slu.se/geoserver/SOS/ows?service=wfs&version=2.0.0&request=GetFeature&typeName=SOS:SpeciesObservations&outputFormat=application/json&CQL_Filter=INTERSECTS(the_geom,Polygon ((760130 7090468, 759931 7090075, 760594 7090169, 760130 7090468)))&count=10

Illegal property name: the_geom for feature type SOS:SpeciesObservations

2 Answers 2

3

Run one request with the default GML outputformat.

https://sosgeo.artdata.slu.se/geoserver/SOS/ows?service=wfs&version=2.0.0&request=GetFeature&typeName=SOS:SpeciesObservations&count=10

Have a look at one geometry

<SOS:pointLocation>
<gml:Point srsName="urn:ogc:def:crs:EPSG::4326" srsDimension="2" gml:id="SpeciesObservations.-PRCMZAB3UX-8XLUkbyq.pointLocation">
<gml:pos>65.9530037430897 19.407185428432143</gml:pos>
</gml:Point>
</SOS:pointLocation>

Edit your query to use the correct geometry name (pointLocation) and notice that the geometries are in EPSG:4326, in Lat-Lon axis order.

Try again

https://sosgeo.artdata.slu.se/geoserver/SOS/ows?service=wfs&version=2.0.0&request=GetFeature&typeName=SOS:SpeciesObservations&CQL_Filter=INTERSECTS(pointLocation,POLYGON (( 62.5089 16.2054, 62.5089 16.2056, 62.5091 16.2056, 62.5091 16.2054, 62.5089 16.2054 )))&count=10&outputFormat=application/json

You will get results

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": "SpeciesObservations.Fe08MZAB3UX-8XLU_1DC",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    16.205531751639,
                    62.5089661326
                ]
            },
            "geometry_name": "pointLocation",
            "properties": {
                "occurrenceId": "urn:lsid:herbarium.emg.umu.se:observation:S*B748*2660",
                "url": null,
                "isPresentObservation": true,
                "dataProviderId": 7,
                "datasetName": "Virtual Herbarium",
                "startDate": "1941-09-29T22:00:00Z",
                "endDate": "1941-09-29T22:00:00Z",
                "modified": null,
                "decimalLatitude": 62.50897,
                "decimalLongitude": 16.20553,
                "coordinateUncertaintyInMeters": 1500,
                "locality": null,
                "municipality": "Ånge",
                "county": "Västernorrland",
                "province": "Medelpad",
                "institutionCode": null,
                "recordedBy": "T. G. Halle",
                "reportedBy": null,
                "habitat": null,
                "occurrenceRemarks": "Medelpad, Torp, Gissjön, sundet, 1-2 m djup",
                "eventRemarks": null,
                "dyntaxaTaxonId": 2660,
                "taxonCategory": "Art",
                "organismGroup": "Mossor",
                "vernacularName": "stor näckmossa",
                "scientificName": "Fontinalis antipyretica",
                "isRedlisted": false,
...
3

If you look at the feature schema (by making a DescribeFeatureType request) you will see that there is no attribute called the_geom, it looks like you have a choice of:

<xsd:element maxOccurs="1" minOccurs="0" name="point" nillable="true" type="gml:GeometryPropertyType" />
<xsd:element maxOccurs="1" minOccurs="0" name="pointLocation" nillable="true" type="gml:PointPropertyType" />

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.