class, layers, getmap_extra_kwargs=None)[source]#

A WMS imagery retriever which can be added to a map.


Requires owslib and Pillow to work.

No caching of retrieved maps is done with this WMSRasterSource.

To reduce load on the WMS server it is encouraged to tile map requests and subsequently stitch them together to recreate a single raster, thus allowing for a more aggressive caching scheme, but this WMSRasterSource does not currently implement WMS tile fetching.

Whilst not the same service, there is also a WMTSRasterSource which makes use of tiles and comes with built-in caching for fast repeated map retrievals.

  • service (string or WebMapService instance) – The WebMapService instance, or URL of a WMS service, from whence to retrieve the image.

  • layers (string or list of strings) – The name(s) of layers to use from the WMS service.

  • getmap_extra_kwargs (dict, optional) – Extra keywords to pass through to the service’s getmap method. If None, a dictionary with {'transparent': True} will be defined.

fetch_raster(projection, extent, target_resolution)[source]#

Return a sequence of images with extents given some constraining information.

  • projection ( – The desired projection of the image.

  • extent (iterable of length 4) – The extent of the requested image in projected coordinates. The resulting image may not be defined exactly by these extents, and so the extent of the resulting image is also returned. The extents must be defined in the form (min_x, max_x, min_y, max_y).

  • target_resolution (iterable of length 2) – The desired resolution of the image as (width, height) in pixels.


images – A sequence of LocatedImage instances.


Extra kwargs passed through to the service’s getmap request.


The names of the layers to fetch.


The OWSLib WebMapService instance.


Raise an error if this raster source cannot provide images in the specified projection.


projection ( – The desired projection of the image.