Skip to content

Commit

Permalink
filter occurrences - add maxyear param
Browse files Browse the repository at this point in the history
  • Loading branch information
vmikk committed May 24, 2023
1 parent 9d9562e commit 9556ef0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bin/10_Filter_occurrences.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ option_list <- list(

## Additional filters
make_option("--minyear", action="store", default=1945, type='integer', help="Minimum year of occurrence (default, 1945)"),
make_option("--maxyear", action="store", default=NA, type='integer', help="Maximum year of occurrence"),
make_option("--noextinct", action="store", default=NA, type='character', help="Remove extinct species (provide a file with extinct specieskeys)"),
make_option("--excludehuman", action="store", default=TRUE, type='logical', help="Exclude human records (genus Homo)"),
make_option("--basisofrecordinclude", action="store", default=NA, type='character', help="Basis of record to include from the data"),
Expand Down Expand Up @@ -125,7 +126,9 @@ POLYGON <- to_na( opt$polygon )
WGSRPD <- to_na( opt$wgsrpd )
WGSRPDREGIONS <- to_na( opt$regions )

MINYEAR <- as.numeric(to_na( opt$minyear) )
MINYEAR <- as.numeric(to_na( opt$minyear) )
MAXYEAR <- as.numeric(to_na( opt$maxyear) )

EXTINCT <- to_na( opt$noextinct )
EXCLUDEHUMAN <- as.logical( opt$excludehuman )

Expand Down Expand Up @@ -165,6 +168,7 @@ cat(paste("WGSRPD regions: ", WGSRPDREGIONS, "\n", sep=""))
cat(paste("Basis of record to include: ", BASISINCL, "\n", sep=""))
cat(paste("Basis of record to exclude: ", BASISEXCL, "\n", sep=""))
cat(paste("Minimum year of occurrence: ", MINYEAR, "\n", sep=""))
cat(paste("Maximum year of occurrence: ", MAXYEAR, "\n", sep=""))
cat(paste("List of extict species: ", EXTINCT, "\n", sep=""))
cat(paste("Exclusion of human records: ", EXCLUDEHUMAN, "\n", sep=""))

Expand Down Expand Up @@ -291,9 +295,13 @@ if(!is.na(BASISINCL) & !is.na(BASISEXCL)){

## Year
if(!is.na(MINYEAR)){
cat("..Filtering by collection date\n")
cat("..Filtering by collection date (min year)\n")
dsf <- dsf %>% filter(year >= MINYEAR)
}
if(!is.na(MAXYEAR)){
cat("..Filtering by collection date (max year)\n")
dsf <- dsf %>% filter(year <= MAXYEAR)
}

## Taxonomy filters
if(!is.na(PHYLUM)){
Expand Down

0 comments on commit 9556ef0

Please sign in to comment.