[GIS] “Layer is not valid” when importing WFS

layersqgiswfs

I try to load a WFS layer but

Analysis of DescribeFeatureType response failed for url restrictToRequestBBOX='1' srsname='EPSG:3877' typename='akaava:Kaava'
url='https://opaskartta.turku.fi/TeklaOGCWeb/WFS.ashx' version='auto'
table="" sql=: it is probably a schema for Complex Features

The URL contains open source information of a city I'm making a map of. The WMS services work just fine but the WFS doesn't work for some reason.

Best Answer

You can't read complex features from that WFS server with QGIS, at least not yet. However, you can use the new GDAL GMLAS driver http://gdal.org/drv_gmlas.html that is currently in GDAL trunk only.

Usage examples:

Get layer list:

ogrinfo -ro WFS:"https://opaskartta.turku.fi/TeklaOGCWeb/WFS.
ashx?service=WFS&request=GetCapabilities"
INFO: Open of `WFS:https://opaskartta.turku.fi/TeklaOGCWeb/WFS.ashx?service=WFS&
request=GetCapabilities'
      using driver `WFS' successful.
Metadata:
  TITLE=Tekla Xcity WFS Server
1: kanta:Kiinteisto (Polygon)
2: kanta:Kiinteistoraja (Line String)
3: kanta:Maaraala (Polygon)
4: kanta:Rajamerkki (Point)
5: kanta:Rakennuspaikka (Polygon)
6: kanta:Kayttooikeusyksikko (Point)
7: kanta:MuuMaa-alue (Point)
...
...

Study structure of one layer:

ogrinfo -ro -so WFS:"https://opaskartta.turku.fi/TeklaOGCWeb/WFS.ashx?service=WFS&request=GetCapabilities" akaava:Kaavayksikko
INFO: Open of `WFS:https://opaskartta.turku.fi/TeklaOGCWeb/WFS.ashx?service=WFS&
request=GetCapabilities'
      using driver `WFS' successful.
Metadata:
  TITLE=Tekla Xcity WFS Server

Layer name: akaava:Kaavayksikko
Metadata:
  TITLE=akaava:Kaavayksikko
Geometry: Polygon
...lots of warnings...
Feature Count: 100
Extent: (23456398.990000, 6697268.529000) - (23474000.214000, 6714794.315000)
Layer SRS WKT:
PROJCS["ETRS89 / GK23FIN",
    GEOGCS["ETRS89",
        DATUM["European_Terrestrial_Reference_System_1989",
            SPHEROID["GRS 1980",6378137,298.257222101,
                AUTHORITY["EPSG","7019"]],
            TOWGS84[0,0,0,0,0,0,0],
            AUTHORITY["EPSG","6258"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4258"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",23],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",23500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","3877"]]
gml_id: String (0.0) NOT NULL
tunnus: Integer (0.0)
kohdekoodi: Integer (0.0)
kaavayksikonTunnus: Integer (0.0)
kaavayksikonlaji: String (0.0)
tonttijaonlaji: String (0.0)
tonttijaontunnus: String (0.0)
kaavallinenOlotila: Integer (0.0)
voimassaolo: String (0.0)
perusmaara: Real (0.0)
kaytetty: Real (0.0)
lisarakennusoikeus: Integer (0.0)
kellaritilat: Integer (0.0)
ullakkotilat: Integer (0.0)
kerrostenLkm: Integer (0.0)
maanalaistenTilojenLkm: Integer (0.0)
kerrosjaonMaaraytymistapa: Integer (0.0)
tehokkuusluku: Real (0.0)
maarittamisTapaKoodi: String (0.0)
pintaAla: Real (0.0)
pintaAlanMaarittamistapa: String (0.0)
kayttotarkoitus: String (0.0)
yksilointitieto: Integer (0.0)
alkuHetki: String (0.0)
kunta: String (0.0)
teksti: String (0.0)
osoitenumero: Integer (0.0)
postinumero: Integer (0.0)
postitoimipaikannimi: String (0.0)

Leave out the -so (summary only switch) and you can print data about the features on screen. You can even try to convert data into SpatiaLite database:

ogr2ogr -f sqlite -dsco spatialite=yes virkistysalue.sqlite WFS:"https://opaskartta.turku.fi/TeklaOGCWeb/WFS.ashx?service=WFS&request=Get
Capabilities" akaava:Virkistysalue -skipfailures

However, the result will have no features. I am not sure if my syntax is wrong or if the error message is right and layers in that service are not configured correctly:

 NOT NULL constraint failed: akaava:virkistysalue.gml_id (19)

As the next steps I would read carefully GDAL GMLAS document page, have a try with saving data from the service into GML with curl and simple GetFeature request, and try if data could be converted better from disk as

ogr2ogr -f sqlite -dsco spatialite=yes GMLAS:virkistysalue.gml

If there are still error messages about schema validation errors contact those who maintain the service.