def gettile(self, base_url=None, layer=None, style=None, format=None,<EOL>tilematrixset=None, tilematrix=None, row=None, column=None,<EOL>**kwargs):
vendor_kwargs = self.vendor_kwargs or {}<EOL>vendor_kwargs.update(kwargs)<EOL>if self.restonly:<EOL><INDENT>resurl = self.buildTileResource(<EOL>layer, style, format, tilematrixset, tilematrix,<EOL>row, column, **vendor_kwargs)<EOL>u = openURL(resurl, username=self.username, password=self.password)<EOL>return u<EOL><DEDENT>data = self.buildTileRequest(layer, style, format, tilematrixset,<EOL>tilematrix, row, column, **vendor_kwargs)<EOL>if base_url is None:<EOL><INDENT>base_url = self.url<EOL>try:<EOL><INDENT>methods = self.getOperationByName('<STR_LIT>').methods<EOL>get_verbs = [x for x in methods<EOL>if x.get('<STR_LIT:type>').lower() == '<STR_LIT>']<EOL>if len(get_verbs) > <NUM_LIT:1>:<EOL><INDENT>base_url = next(<EOL>x for x in filter(<EOL>list,<EOL>([pv.get('<STR_LIT:url>')<EOL>for const in pv.get('<STR_LIT>')<EOL>if '<STR_LIT>' in [x.lower() for x in const.values]]<EOL>for pv in get_verbs if pv.get('<STR_LIT>'))))[<NUM_LIT:0>]<EOL><DEDENT>elif len(get_verbs) == <NUM_LIT:1>:<EOL><INDENT>base_url = get_verbs[<NUM_LIT:0>].get('<STR_LIT:url>')<EOL><DEDENT><DEDENT>except StopIteration:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>u = openURL(base_url, data, username=self.username,<EOL>password=self.password)<EOL>if u.info()['<STR_LIT:Content-Type>'] == '<STR_LIT>':<EOL><INDENT>se_xml = u.read()<EOL>se_tree = etree.fromstring(se_xml)<EOL>err_message = six.text_type(se_tree.find('<STR_LIT>').text)<EOL>raise ServiceException(err_message.strip(), se_xml)<EOL><DEDENT>return u<EOL>
Return a tile from the WMTS.

        Returns the tile image as a file-like object.

        Parameters
        ----------
        base_url : string
            Optional URL for request submission. Defaults to the URL of
            the GetTile operation as declared in the GetCapabilities
            response.
        layer : string
            Content layer name.
        style : string
            Optional style name. Defaults to the first style defined for
            the relevant layer in the GetCapabilities response.
        format : string
            Optional output image format,  such as 'image/jpeg'.
            Defaults to the first format defined for the relevant layer
            in the GetCapabilities response.
        tilematrixset : string
            Optional name of tile matrix set to use.
            Defaults to the first tile matrix set defined for the
            relevant layer in the GetCapabilities response.
        tilematrix : string
            Name of the tile matrix to use.
        row : integer
            Row index of tile to request.
        column : integer
            Column index of tile to request.
        **kwargs : extra arguments
            anything else e.g. vendor specific parameters

        Example
        -------
            >>> url = 'http://map1c.vis.earthdata.nasa.gov/wmts-geo/wmts.cgi'
            >>> wmts = WebMapTileService(url)
            >>> img = wmts.gettile(layer='VIIRS_CityLights_2012',\
                                   tilematrixset='EPSG4326_500m',\
                                   tilematrix='6',\
                                   row=4, column=4)
            >>> out = open('tile.jpg', 'wb')
            >>> bytes_written = out.write(img.read())
            >>> out.close()