Converts a data.frame of species occurrences into input features to use a convolutional neural network to approximate species extinction risk.

iucnn_cnn_features(
  x,
  y = NULL,
  species = "species",
  lon = "decimallongitude",
  lat = "decimallatitude",
  crs_x = "+proj=longlat +datum=WGS84",
  res_y = 1
)

Arguments

x

a data.frame with at least three columns containing taxon name, decimal longitude and latitude values.

y

a SpatRaster object as reference to count the number of occurrence records in. Can be of any resolution and CRS but the coordinates in x need to be in the same CRS.

species

a character string. The name of the column with the species names.

lon

a character string. The name of the column with the longitude.

lat

a character string. The name of the column with the latitude.

crs_x

a proj4string specifying the Coordinate Reference system of the coordinates in x. Default is to lat/lon WGS84.

res_y

numeric. The resolution for the raster in decimal degrees. Only relevant if y is not provided.

Value

a list of matrices, one for each input species, where the cells represent the number of occurrence records in this cell as input for the “cnn” class of iucnn_train_model.

Details

If y is not provided, assumes a lat/lon grid with extent equal to the respective minimum and maximum in x

Examples

if (FALSE) {
dat <- data.frame(species = c("A","B"),
                  decimallongitude = runif(200, 10, 15),
                  decimallatitude = runif(200, -5, 5))

iucnn_cnn_features(dat)
}