1

I am trying to download some Dutch open data through a WFS, but I get a DriverError. It seems to be a geopandas problem, but I cannot find or think of a solution. I'll provide my code below and hopefully someone can identify my problem.

Code (optained from this question: Reading data to geopandas using WFS?):

from requests import Request
from owslib.wfs import WebFeatureService

# URL for WFS backend
url = "https://geodata.nationaalgeoregister.nl/natura2000/wfs?request=GetCapabilities&service=wfs"

# Initialize
wfs = WebFeatureService(url=url)

# Get data from WFS
# -----------------

# Fetch the last available layer (as an example) --> 'vaestoruutu:vaki2017_5km'
layer = list(wfs.contents)[-1]

# Specify the parameters for fetching the data
params = dict(service='WFS', version="1.0.0", request='GetFeature',
      typeName=layer, outputFormat='json')

# Parse the URL with parameters
q = Request('GET', url, params=params).prepare().url

# Read data from URL
data = gpd.read_file(q)

The error message:

     22 q = Request('GET', url, params=params).prepare().url
     24 # Read data from URL
---> 25 data = gpd.read_file(q)

File ~\Anaconda3\envs\PDOK\lib\site-packages\geopandas\io\file.py:160, in _read_file(filename, bbox, mask, rows, **kwargs)
    157     reader = fiona.open
    159 with fiona_env():
--> 160     with reader(path_or_bytes, **kwargs) as features:
    161 
    162         # In a future Fiona release the crs attribute of features will
    163         # no longer be a dict, but will behave like a dict. So this should
    164         # be forwards compatible
    165         crs = (
    166             features.crs["init"]
    167             if features.crs and "init" in features.crs
    168             else features.crs_wkt
    169         )
    171         # handle loading the bounding box

File ~\Anaconda3\envs\PDOK\lib\site-packages\fiona\collection.py:555, in BytesCollection.__init__(self, bytesbuf, **kwds)
    552 self.virtual_file = buffer_to_virtual_file(self.bytesbuf, ext=ext)
    554 # Instantiate the parent class.
--> 555 super(BytesCollection, self).__init__(self.virtual_file, vsi=filetype, **kwds)

File ~\Anaconda3\envs\PDOK\lib\site-packages\fiona\collection.py:171, in Collection.__init__(self, path, mode, driver, schema, crs, encoding, layer, vsi, archive, enabled_drivers, crs_wkt, ignore_fields, ignore_geometry, **kwargs)
    168     raise
    170 if self.session is not None:
--> 171     self.guard_driver_mode()
    173 if self.mode in ("a", "w"):
    174     self._valid_geom_types = _get_valid_geom_types(self.schema, self.driver)

File ~\Anaconda3\envs\PDOK\lib\site-packages\fiona\collection.py:188, in Collection.guard_driver_mode(self)
    186 driver = self.session.get_driver()
    187 if driver not in supported_drivers:
--> 188     raise DriverError("unsupported driver: %r" % driver)
    189 if self.mode not in supported_drivers[driver]:
    190     raise DriverError("unsupported mode: %r" % self.mode)

DriverError: unsupported driver: 'WFS'

I am quite new to this.

1 Answer 1

3

That sample code was missing an important bit, enabling WFS support in fiona. Fiona doesn't support WFS by default.

Add the following near the top of your script:

# enable WFS support
import fiona
fiona.drvsupport.supported_drivers['WFS'] = 'r'
2
  • Thanks, this worked for this wfs!
    – SJAAK
    Mar 17 at 11:24
  • For another WFS (geodata.nationaalgeoregister.nl/nwbvaarwegen/…) I get another error however: fiona.errors.DriverError: '/vsimem/4ec3f86c094340cc8704fe5b9aa0f517' not recognized as a supported file format. Do you know what this means?
    – SJAAK
    Mar 17 at 11:25

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.