0

I am trying to get the bbox for a particular feature for a layer from my geoserver. For this I am trying using the following url:

http://example.com/geoserver/wfs?version=1.3.0&request=describeFeatureType&outputFormat=application/json&service=WFS&typeName=layerName&PROPERTYNAME=(DISTNAME,Sylhet)

Ok fine, I am getting the bbox in the response. But the response gives me the coordinates for that particular feature too. Its very clumsy to me and I just want the bbox as response not the coordinate.

For this how can I change my request?? Please help.

4
  • Your query is a bit odd. You use version 1.3.0 but such WFS version does not exist, and you make a DescribeFeatureType request that should return the schema of the featuretype but no coordinates at all. Did you really use just that query?
    – user30184
    Commented Feb 7, 2017 at 9:19
  • yap, I just used this.
    – cjahangir
    Commented Feb 7, 2017 at 9:22
  • Very odd. I am not sure if GeoServer should give an error about non-existing version but it does not seem to do that. Anyway, this server sends the schema which makes sense demo.opengeo.org/geoserver/… with query http://demo.opengeo.org/geoserver/wfs?version=1.3.0&request=describeFeatureType&outputFormat=application/json&service=WFS&typeName=topp:states
    – user30184
    Commented Feb 7, 2017 at 9:53
  • Very odd, I can get this to return: http://demo.opengeo.org/geoserver/wfs?service=WFS&request=DescribeFeatureType&typename=topp:states&outputFormat=text/xml;%20subtype=gml/3.1.1& that's without any version at all.
    – nmtoken
    Commented Feb 7, 2017 at 13:53

2 Answers 2

2

WFS has no way to just provide the bounding box of a feature.

However, you can install the WPS protocol, it has a process you can use to just extract the bounding box. It's going to be a complex POST request, you can build a sample of it using the "WPS builder" in the demo section

0
0

In your example request you are trying to obtain a bounding box from a description of a FeatureType, that could never work; the description tells you what type of data can exist in an actual Feature of that type:

So a DescribeFeatureType request for the type topp:states gives us:

<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:gml="http://www.opengis.net/gml" xmlns:maps="http://boundlessgeo.com" xmlns:nasa="http://nasa.gov" xmlns:ne="http://naturalearthdata.com" xmlns:nurc="http://www.nurc.nato.int" xmlns:og="http://opengeo.org" xmlns:osm="http://openstreemap.org" xmlns:topp="http://www.openplans.org/topp" xmlns:usgs="http://www.usgs.gov/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.openplans.org/topp">
  <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://demo.opengeo.org:80/geoserver/schemas/gml/3.1.1/base/gml.xsd"/>
  <xsd:complexType name="statesType">
    <xsd:complexContent>
      <xsd:extension base="gml:AbstractFeatureType">
        <xsd:sequence>
          <xsd:element maxOccurs="1" minOccurs="0" name="the_geom" nillable="true" type="gml:MultiSurfacePropertyType"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="STATE_NAME" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="STATE_FIPS" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="SUB_REGION" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="STATE_ABBR" nillable="true" type="xsd:string"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="LAND_KM" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="WATER_KM" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="PERSONS" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="FAMILIES" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="HOUSHOLD" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="MALE" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="FEMALE" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="WORKERS" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="DRVALONE" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="CARPOOL" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="PUBTRANS" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="EMPLOYED" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="UNEMPLOY" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="SERVICE" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="MANUAL" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="P_MALE" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="P_FEMALE" nillable="true" type="xsd:double"/>
          <xsd:element maxOccurs="1" minOccurs="0" name="SAMP_POP" nillable="true" type="xsd:double"/>
        </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>
  <xsd:element name="states" substitutionGroup="gml:_Feature" type="topp:statesType"/>
</xsd:schema>

It tells us that topp:states can have a geometry, but not what the values are.

If you want the bounding box for the set of features that are of type topp:states then you just need to do a GetCapabilities request, so the following request http://demo.opengeo.org/geoserver/wfs?service=WFS&request=GetCapabilities& tells us:

<FeatureType xmlns:topp="http://www.openplans.org/topp">
    <Name>topp:states</Name>
    <Title>USA Population</Title>
    <Abstract>2000 census data for United States.</Abstract>
    <ows:Keywords>
        <ows:Keyword>census</ows:Keyword>
        <ows:Keyword>united</ows:Keyword>
        <ows:Keyword>boundaries</ows:Keyword>
        <ows:Keyword>state</ows:Keyword>
        <ows:Keyword>states</ows:Keyword>
    </ows:Keywords>
    <DefaultCRS>urn:ogc:def:crs:EPSG::4326</DefaultCRS>
    <ows:WGS84BoundingBox>
        <ows:LowerCorner>-124.731422 24.955967</ows:LowerCorner>
        <ows:UpperCorner>-66.969849 49.371735</ows:UpperCorner>
    </ows:WGS84BoundingBox>
</FeatureType>

If you want to find information about a feature of type topp:states, you need to do a GetFeature request. If you want to get a feature by its identifier, then there is a stored procedure that will allow you to do this.

So for example to find out information about the topp:states feature with ID `states.1' you could use (returning JSON):

http://demo.opengeo.org/geoserver/wfs?service=WFS&version=2.0.0&request=GetFeature&STOREDQUERY_ID=urn:ogc:def:query:OGC-WFS::GetFeatureById&ID=states.1&outputformat=json&

and for information about the topp:states feature with ID `states.30' you could use (returning XML):

http://demo.opengeo.org/geoserver/wfs?service=WFS&version=2.0.0&request=GetFeature&STOREDQUERY_ID=urn:ogc:def:query:OGC-WFS::GetFeatureById&ID=states.30&

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.