createEnv: Create env file from raster file(s) and/or global database...

Description Usage Arguments Details Value Author(s) Examples

View source: R/Preprocessing.R

Description

Create env file as an input for SamBada (it is recommended to run prepare_env function before running samBada) raster file(s) and/or global database present in the raster r package

Usage

1
2
3
4
5
createEnv(locationFileName, outputFile, x = NULL, y = NULL,
  locationProj = NULL, separator = ",", worldclim = TRUE,
  resWC = 0.5, srtm = FALSE, saveDownload, rasterName = NULL,
  rasterProj = NULL, directory = FALSE, interactiveChecks,
  verbose = TRUE)

Arguments

locationFileName

char Name of the file containing location of individuals. Must be in the active directory. Supported extension are .csv, .shp. All columns present in this file will also be present in the output file

outputFile

char Name of the output file. Must have a .csv extension.

x

char Name of the x (or longitude if not projected coordinate system) column in the locationFileName. Required if locationFileName extension is .csv

y

char Name of the y (or latitude if not projected coordinate system) column in the locationFileName. Required if locationFileName extension is .csv

locationProj

integer Coordinate system EPSG code of the locationFileName. If locationFileName is already georeferenced, this argument will be skipped. Required if locationFileName extension is csv.

separator

char The separator used to separate columns in your locationFileName

worldclim

logical If TRUE worldclim bio, tmin, tmax and prec variables will be downloaded at a resolution of 0.5 minutes of degree (the finest resolution). Rely rgdal and gdalUtils R package to merge the tiles. The downloaded tiles will be stored in the (new) wc0.5 directory of the active directory

resWC

double The resolution at which to download the worldclim tiles. Must be one of 0.5, 2.5, 5, and 10 (minutes of degree). See argument res of raster::getData.

srtm

logical If TRUE the SRTM (altitude) variables will be downloaded at a resolution ... Rely rgdal and gdalUtils R package to merge the tiles. The downloaded tiles will be stored in the (new) wc0.5 directory of the active directory

saveDownload

logical If TRUE (and if worldclim or srtm is TRUE), the tiles downloaded from global databases will be saved in a non-temporary directory. We recommend setting this parameter to true so that rasters can be used later (post-processing). If worldclim and srtm are FALSE, either value (TRUE/FALSE) will have no effect

rasterName

char or list Name or list of name of raster files to import. Supported format are the one of raster package. If directory is TRUE then the path to the directory. Can be set to null if worldclim or srtm are set to TRUE.

rasterProj

integer or list of integer Coordinate system EPSG code of the rasterlayer. If rasterlayer is already georeferenced, this argument will be skipped. If rasterName is a list, can be either a single number if all projections are the same or a list of projection for all files if different. If directory is TRUE, can only contain one number (all projections must be equal or rasters must be georeferenced)

directory

logical If true, all .tif, .gtiff, .img, .sdat, . present in rasterName will be loaded

interactiveChecks

logical If TRUE, shows loaded rasters and point locations

verbose

logical If TRUE, indication on process will be shown

Details

If you set worldclim=TRUE, then tmin10 represents the minimum temperature in October. Similarly tmax, tavg and prec refers to maximum temperature, average temperature and precipitation. The bio1-bio19 are bioclim variables are computed from these indices and are described here. Temperature are given in 10 degree C and precipitation in mm. The function always downloads the best resolution available (30 seconds for worldclim dataset and 90m for SRTM). This function requires that you define the EPSG code of your projection system. If you work with lat/long global projection, then you most probably work with WGS 84 whose EPSG is 4326.

In order to work, this function needs GDAL to be installed on your machine (requirements of the package rgdal)

Value

None

Author(s)

Solange Duruz

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
# Worldclim download only with sample data from R.SamBada
createEnv(locationFileName=system.file("extdata", "uganda-subset.csv", package = "R.SamBada"),
      outputFile=file.path(tempdir(),'uganda-subset-env.csv'), x='longitude',y='latitude',
      locationProj=4326, worldclim=TRUE,saveDownload=FALSE,interactiveChecks=TRUE)
      
# Own raster (fictitious examples) + worldclim download
createEnv(rasterName=c('prec.tif','tmin.sdat'),locationFileName='MyFile.shp',
      outputFile='MyFile-env.csv', rasterProj=c(4326,21781), worldclim=TRUE,
      saveDownload=TRUE,interactiveChecks=TRUE)

## End(Not run)

R.SamBada documentation built on Dec. 1, 2019, 1:28 a.m.