class_docstr: A WMS imagery retriever which can be added to a map.
  
  Note
  ----
      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.
class_docstr_tok: ["A","WMS","imagery","retriever","which","can","be","added","to","a","map",".","Note","--","--","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","."]
docstr: Parameters
  ----------
  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.
docstr_tok: ["Parameters","--","--","--","--","--","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","."]
code: def __init__(self, service, layers, getmap_extra_kwargs=None):
      """
      Parameters
      ----------
      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.
  
      """
      if WebMapService is None:
          raise ImportError(_OWSLIB_REQUIRED)
  
      if isinstance(service, str):
          service = WebMapService(service)
  
      if isinstance(layers, str):
          layers = [layers]
  
      if getmap_extra_kwargs is None:
          getmap_extra_kwargs = {"transparent": True}
  
      if len(layers) == 0:
          raise ValueError("One or more layers must be defined.")
      for layer in layers:
          if layer not in service.contents:
              raise ValueError(
                  f"The {layer!r} layer does not exist in "
                  "this service."
              )
  
      #: The OWSLib WebMapService instance.
      self.service = service
  
      #: The names of the layers to fetch.
      self.layers = layers
  
      #: Extra kwargs passed through to the service's getmap request.
      self.getmap_extra_kwargs = getmap_extra_kwargs
  
imports: import collections
  import io
  import math
  from urllib.parse import urlparse
  import warnings
  import weakref
  from xml.etree import ElementTree
  import numpy
  from PIL import Image
  import shapely.geometry
  import cartopy.crs
  from cartopy.img_transform import warp_array
  from cartopy.io import LocatedImage, RasterSource
label_desc: Use image node_id 1 to create a new WMSRasterSource object from inherited base classes: RasterSource with example: obj = WMSRasterSource(service, layers, getmap_extra_kwargs)