class_docstr: A WMTS imagery retriever which can be added to a map.
  
  Uses tile caching for fast repeated map retrievals.
  
  Note
  ----
      Requires owslib and Pillow to work.
class_docstr_tok: ["A","WMTS","imagery","retriever","which","can","be","added","to","a","map",".","Uses","tile","caching","for","fast","repeated","map","retrievals",".","Note","--","--","Requires","owslib","and","Pillow","to","work","."]
docstr: Parameters
  ----------
  wmts
      The URL of the WMTS, or an owslib.wmts.WebMapTileService instance.
  layer_name
      The name of the layer to use.
  gettile_extra_kwargs: dict, optional
      Extra keywords (e.g. time) to pass through to the
      service's gettile method.
docstr_tok: ["Parameters","--","--","--","--","--","wmts","The","URL","of","the","WMTS",",","or","an","owslib.wmts.WebMapTileService","instance",".","layer_name","The","name","of","the","layer","to","use",".","gettile_extra_kwargs",":","dict",",","optional","Extra","keywords","(","e.g",".","time",")","to","pass","through","to","the","service","'s","gettile","method","."]
code: def __init__(self, wmts, layer_name, gettile_extra_kwargs=None):
      """
      Parameters
      ----------
      wmts
          The URL of the WMTS, or an owslib.wmts.WebMapTileService instance.
      layer_name
          The name of the layer to use.
      gettile_extra_kwargs: dict, optional
          Extra keywords (e.g. time) to pass through to the
          service's gettile method.
  
      """
      if WebMapService is None:
          raise ImportError(_OWSLIB_REQUIRED)
  
      if not (
          hasattr(wmts, "tilematrixsets")
          and hasattr(wmts, "contents")
          and hasattr(wmts, "gettile")
      ):
          wmts = owslib.wmts.WebMapTileService(wmts)
  
      try:
          layer = wmts.contents[layer_name]
      except KeyError:
          raise ValueError(
              f"Invalid layer name {layer_name!r} for WMTS at {wmts.url!r}"
          )
  
      #: The OWSLib WebMapTileService instance.
      self.wmts = wmts
  
      #: The layer to fetch.
      self.layer = layer
  
      #: Extra kwargs passed through to the service's gettile request.
      if gettile_extra_kwargs is None:
          gettile_extra_kwargs = {}
      self.gettile_extra_kwargs = gettile_extra_kwargs
  
      self._matrix_set_name_map = {}
  
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 WMTSRasterSource object from inherited base classes: RasterSource with example: obj = WMTSRasterSource(wmts, layer_name, gettile_extra_kwargs)