Here a short code (not strong enough for all errors but works in QGIS 3.x) for export to export_dir a file_name for the layer layer_name :
export_dir = "/home/me/my_dir/"
layer_name = "Exceptions"
file_name = "Exceptions.txt"
valid = True
lyr = QgsProject.instance().mapLayersByName(layer_name)
You are trying to export an image collection (multiple images) while you can export only one image. Filter that image collection. Use for example collection.first() to get the first image in that collection. Or try to use clipped as image instead of collection in your export call
To extract your data open the attribute table and create a new field via fieldcalculator. Make sure to set datatype, precision and so on as you need it. Use $y to extract y-coordinate, $x to extract x-coordinate and z($geometry) to extract z-coordinate. (Not sure if $z will work).
In case you only want to extract coordinates and save them to a csv file, you ...
In QGIS, you can find a tool in Vector/Data Management Tools/Split Vector Layer.
There you can define the column containing the species information as Unique ID field and it will generate a new file for each category in the output directory.
This calls for a custom geoprocessing tool:
Alle the features in a shapefile are clipped form the source raster and saved as a separate file with same properties. You can run this script in the qgis python editor after changing the path and filenames.
import os, sys
from osgeo import gdal, gdalnumeric, ogr, osr
import numpy as np
# config, all your data ...