0

I'm trying to retrieve DefaultCRS for one layers from WFS 2.0.0.

For the moment, only way I find is to use GetCapabilities and reduce the xml file by setting the sections like that :

https://wxs.ign.fr/environnement/geoportail/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities&SECTIONS=FeatureTypeList

Is there a way to directly ask metadata for only one layer?

I also tried CSW but it wasn't conclusive.


Respond to @nmtoken comment.

I tried both method.

Set count = 1 to GetFeature is a double edge sword because for some ressources features are quite simple and the response time is fast but sometime features are quite complexe and loading the geometry takes more time than call GetCapabilities.

GetPropertyValue only list possible value for attribute but there are no columns corresponding to CRS. However, when setting valueReference=the_geom the third node of xml response contain CRS.

Normally, the argument valueReference can handle XPath() expression so I can select the third node attributs after url encoding with something like : valueReference=the_geom/wfs:member/LIMITES_ADMINISTRATIVES_EXPRESS.LATEST:the_geom/gml:MultiSurface or more simply with valueReference=the_geom[3]

In both case it's not working in my example :

# First try
https://wxs.ign.fr/administratif/geoportail/wfs?service=WFS&version=2.0.0&request=GetPropertyValue&typeNames=LIMITES_ADMINISTRATIVES_EXPRESS.LATEST%3Acommune&valueReference=valueReference=the_geom%2Fwfs%3Amember%2FLIMITES_ADMINISTRATIVES_EXPRESS.LATEST%3Athe_geom%2Fgml%3AMultiSurface&count=1&outputFormat=gml32

# Second try
https://wxs.ign.fr/administratif/geoportail/wfs?service=WFS&version=2.0.0&request=GetPropertyValue&typeNames=LIMITES_ADMINISTRATIVES_EXPRESS.LATEST%3Acommune&valueReference=the_geom%5B3%5D&count=1&outputFormat=gml32

If anyone already used valueReference with XPath expression can you check if mine are correct ?

2
  • 1
    getCapabilities is the "correct" (and I suspect only) way of getting information about the layers of a service.
    – Ian Turton
    Commented Dec 30, 2022 at 14:47
  • 1
    If you know the Feature Type (layer) name then you could try a GetFeature request with count of 1, and restrict information returned by filtering by properties. Or possibly you could use a GetPropertyValue request
    – nmtoken
    Commented Jan 1, 2023 at 15:30

1 Answer 1

0

The WFS 2.0 standard https://docs.ogc.org/is/09-025r2/09-025r2.html defines that the DefaultCRS is reported within GetCapabilites, in the FeatureTypeList element. The response must contain the full list of feature types. The

The wfs:FeatureTypeList element shall contain a list of feature types, subtyped from gml:AbstractFeatureType, that a WFS offers.

A fragment of the schema of the response:

 <xsd:complexType name="FeatureTypeType"> 
      <xsd:sequence> 
         <xsd:element name="Name" type="xsd:QName"/> 
         <xsd:element ref="wfs:Title" minOccurs="0" maxOccurs="unbounded"/> 
         <xsd:element ref="wfs:Abstract" minOccurs="0" maxOccurs="unbounded"/> 
         <xsd:element ref="ows:Keywords" minOccurs="0" maxOccurs="unbounded"/> 
         <xsd:choice> 
            <xsd:sequence> 
               <xsd:element name="DefaultCRS" type="xsd:anyURI"/> 
               <xsd:element name="OtherCRS" type="xsd:anyURI" 
                            minOccurs="0" maxOccurs="unbounded"/> 
            </xsd:sequence> 
            <xsd:element name="NoCRS"> 
               <xsd:complexType/> 
            </xsd:element> 
         </xsd:choice> 

GetCapabilities response must contain DefaultCRS information about all the layers and therefore it is safe to read that information from GetCaps. I think it is also the only safe way. Reading one geometry without defining srsName is a good workaround.

The wfs:DefaultCRS element indicates which coordinate reference system shall be used by a WFS to express the state of a spatial feature if not otherwise explicitly identified within a query or transaction request.

However, if the schema of the selected feature type allows null geometries then it is possible that GetFeature with count=1 does not return a geometry for finding the CRS.

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.