def get_chip(self, coordinates, catid, chip_type='<STR_LIT>', chip_format='<STR_LIT>', filename='<STR_LIT>'):
def t2s1(t):<EOL><INDENT>return str(t).strip('<STR_LIT>').replace('<STR_LIT:U+002C>', '<STR_LIT>')<EOL><DEDENT>def t2s2(t):<EOL><INDENT>return str(t).strip('<STR_LIT>').replace('<STR_LIT:U+0020>', '<STR_LIT>')<EOL><DEDENT>if len(coordinates) != <NUM_LIT:4>:<EOL><INDENT>print('<STR_LIT>')<EOL>return False<EOL><DEDENT>W, S, E, N = coordinates<EOL>box = ((W, S), (W, N), (E, N), (E, S), (W, S))<EOL>box_wkt = '<STR_LIT>' + '<STR_LIT:U+002C>'.join([t2s1(corner) for corner in box]) + '<STR_LIT>'<EOL>results = self.get_images_by_catid_and_aoi(catid=catid, aoi_wkt=box_wkt)<EOL>description = self.describe_images(results)<EOL>pan_id, ms_id, num_bands = None, None, <NUM_LIT:0><EOL>for catid, images in description.items():<EOL><INDENT>for partnum, part in images['<STR_LIT>'].items():<EOL><INDENT>if '<STR_LIT>' in part.keys():<EOL><INDENT>pan_id = part['<STR_LIT>']['<STR_LIT:id>']<EOL>bucket = part['<STR_LIT>']['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in part.keys():<EOL><INDENT>ms_id = part['<STR_LIT>']['<STR_LIT:id>']<EOL>num_bands = <NUM_LIT:8><EOL>bucket = part['<STR_LIT>']['<STR_LIT>']<EOL><DEDENT>elif '<STR_LIT>' in part.keys():<EOL><INDENT>ms_id = part['<STR_LIT>']['<STR_LIT:id>']<EOL>num_bands = <NUM_LIT:4><EOL>bucket = part['<STR_LIT>']['<STR_LIT>']<EOL><DEDENT><DEDENT><DEDENT>band_str = '<STR_LIT>'<EOL>if chip_type == '<STR_LIT>':<EOL><INDENT>band_str = pan_id + '<STR_LIT>'<EOL><DEDENT>elif chip_type == '<STR_LIT>':<EOL><INDENT>band_str = ms_id + '<STR_LIT:?>'<EOL><DEDENT>elif chip_type == '<STR_LIT>':<EOL><INDENT>if num_bands == <NUM_LIT:8>:<EOL><INDENT>band_str = ms_id + '<STR_LIT>' + pan_id<EOL><DEDENT>elif num_bands == <NUM_LIT:4>:<EOL><INDENT>band_str = ms_id + '<STR_LIT>' + pan_id<EOL><DEDENT><DEDENT>location_str = '<STR_LIT>'.format(t2s2((W, N)), t2s2((E, S)))<EOL>service_url = '<STR_LIT>' + bucket + '<STR_LIT:/>'<EOL>url = service_url + band_str + location_str<EOL>url += '<STR_LIT>' + chip_format + '<STR_LIT>' + self.gbdx_connection.access_token<EOL>r = requests.get(url)<EOL>if r.status_code == <NUM_LIT:200>:<EOL><INDENT>with open(filename, '<STR_LIT:wb>') as f:<EOL><INDENT>f.write(r.content)<EOL>return True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL>return False<EOL><DEDENT>
Downloads a native resolution, orthorectified chip in tif format
        from a user-specified catalog id.

        Args:
            coordinates (list): Rectangle coordinates in order West, South, East, North.
                                West and East are longitudes, North and South are latitudes.
                                The maximum chip size is (2048 pix)x(2048 pix)
            catid (str): The image catalog id.
            chip_type (str): 'PAN' (panchromatic), 'MS' (multispectral), 'PS' (pansharpened).
                             'MS' is 4 or 8 bands depending on sensor.
            chip_format (str): 'TIF' or 'PNG'
            filename (str): Where to save chip.

        Returns:
            True if chip is successfully downloaded; else False.