1

I'm trying to use the OS Features API to retrieve Greenspace within a Polygon. The OS example here demonstrates how this is supposedly possible, but when I try the same I cannot retrieve features.

I have tried the following request:

https://api.os.uk/features/v1/wfs

with the following query parameters:

service: wfs
version: 2.0.0
request: GetFeature
typeNames: Zoomstack_Greenspace
key: {{apiKey}}
outputFormat: GeoJSON
srsName: EPSG:27700

and with filter using a Box I can successfully perform the request. E.g:

<ogc:Filter>
    <ogc:Intersects>
      <PropertyName>SHAPE</PropertyName>
      <gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:27700">
        <gml:coordinates decimal="." cs="," ts=",">
          436833.50,115334.90,437643.25,115761.50
        </gml:coordinates>
      </gml:Box>
    </ogc:Intersects>
</ogc:Filter>

However with a Polygon instead of a Box:

<ogc:Filter>
    <ogc:Intersects>
      <PropertyName>SHAPE</PropertyName>
      <gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:27700">
        <gml:coordinates>
          50.887107036372456,-2.154858 50.88639653297961,-2.1727248289496877 50.88427629228161,-2.1903082756046826 50.88077994091106,-2.207329528785897 50.87596292035441,-2.2235188409425026 50.86990159348424,-2.2386198651224105 50.86269201523514,-2.2523937627337745 50.854448388409246,-2.2646230132048037 50.84530123083424,-2.2751148627716202 50.83539528479962,-2.2837043569030944 50.824887203781635,-2.2902569090877254 50.81394305486918,-2.2946703676231017 50.80273567797704,-2.296876551419408 50.791441944852124,-2.2968422354151756 50.78023996203597,-2.2945695757801494 50.76930626235205,-2.2900959744428824 50.758813029162525,-2.2834933914533937 50.74892539662549,-2.27486712212967 50.73979886752439,-2.2643540637301953 50.731576887993434,-2.2521205034652243 50.72438861568274,-2.2383594659603663 50.718346914659264,-2.2232876637972807 50.71354660668353,-2.2071420994805577 50.71006300450259,-2.1901763711362343 50.70795074851218,-2.1726567374662666 50.70724296362755,-2.154858 50.70795074851218,-2.137059262533733 50.71006300450259,-2.1195396288637656 50.71354660668353,-2.102573900519442 50.718346914659264,-2.086428336202719 50.72438861568274,-2.0713565340396336 50.731576887993434,-2.057595496534775 50.73979886752439,-2.0453619362698046 50.74892539662549,-2.0348488778703295 50.758813029162525,-2.026222608546606 50.76930626235205,-2.0196200255571175 50.78023996203597,-2.015146424219851 50.791441944852124,-2.012873764584824 50.80273567797704,-2.012839448580592 50.81394305486918,-2.015045632376898 50.824887203781635,-2.019459090912274 50.83539528479962,-2.0260116430969055 50.84530123083424,-2.034601137228379 50.854448388409246,-2.045092986795196 50.86269201523514,-2.0573222372662254 50.86990159348424,-2.071096134877589 50.87596292035441,-2.0861971590574973 50.88077994091106,-2.102386471214103 50.88427629228161,-2.1194077243953173 50.88639653297961,-2.1369911710503118 50.887107036372456,-2.154858
        </gml:coordinates>
      </gml:Polygon>
    </ogc:Intersects>
</ogc:Filter>

I get the error:

<?xml version="1.0" encoding="utf-8" ?>
<ExceptionReport
 version="2.0.0" xmlns="http://www.opengis.net/ows/1.1"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsAll.xsd"
>
    <Exception exceptionCode="InvalidParameterValue" locator="Unknown">
        <ExceptionText>
            <![CDATA[The geometry was not recognized.]]>
        
        </ExceptionText>
    </Exception>
    <Exception exceptionCode="OperationProcessingFailed" locator="Unknown">
        <ExceptionText>
            <![CDATA[Operator 'Intersects' can't parse geometry.]]>
        
        </ExceptionText>
    </Exception>
</ExceptionReport>

Am I doing something wrong with the XML structure here, or am I not able to query Zoomstack_Greenspace which intersects with a polygon?

2
  • looks like your using lat/lng where your srsName is in (OSGB 1936) Eastings and Northings - switch to srsName: 'urn:ogc:def:crs:EPSG::4326' should help
    – Mapperz
    Jul 15 at 13:22
  • Good point - I've updated that but still see the same error message...
    – Dulcie
    Jul 15 at 13:23
1

Turns out this was a case of bad formatting, and the API handling syntax errors by returning generic XML.

I missed the > off the Polygon definition, which resulted in this error being shown. Interestingly, using posLine rather than coordinates doesn't work at all, and results in an even less helpful XML response!

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.