ncdf4_convert_from_path {TargetSearch} | R Documentation

## Convert CDF files to CDF4 from a path automatically

### Description

Scan and convert NetCDF format 3 files into a custom TargetSearch NetCDF format 4 automatically. The function scans the given input path(s) for files with `"cdf"` extension. This function simply wraps around `ncdf4_convert()`, so that function will then convert each detected file.

### Usage

    ncdf4_convert_from_path(cdf_path = ".", out_path = cdf_path, recursive = FALSE, ignore.case = TRUE, ...)

### Arguments

`cdf_path` | Character string. The path(s) to scan for CDF files.
`out_path` | Character string. The output path(s) in which the converted files will be saved.
`recursive` | Logical. Should the search recurse into directories?
`ignore.case` | Logical. Should the file extension matching be case insensitive?
`...` | Extra options passed to `ncdf4_convert()`, which in turn can be passed to `baseline()`.

### Details

This function simply searches for CDF-3 files and converts them to CDF-4 (custom format). By default the current path is scanned and files are converted and save in the same place.

Multiple input directories can be given. If this is the case, the output path `out_path` must be either a single path (in which case all files will be copied to the same directory) or an equal number of paths, such that there is a corresponding match between input and output directories. If not, an assertion error will be raised.

By default the search is case insensitive (see parameter `ignore.case`). For sensitive case matching, the function looks for all lowercase extension `cdf`. At the moment, it is not possible to change this pattern.

If `recursive` is `TRUE`, the search will also descend into subdirectories and the converted files will follow a similar directory structure. Output directories will be created on demand if required (this is actually done by `ncdf4_convert()` internally).

### Value

A character vector of generated files or invisible.

### Author(s)

Alvaro Cuadros-Inostroza

### See Also

`ncdf4_convert()`, `baseline()`

### Examples

    ## Not run:
    # get files from package TargetSearchData
    require(TargetSearchData)
    cdfpath <- file.path(find.package("TargetSearchData"), "gc-ms-data")
    ncdf4_convert_from_path(cdfpath, ".")

    # recursive search. note that output files will be saved under "gc-ms-data"
    cdfpath <- find.package("TargetSearchData")
    ncdf4_convert_from_path(cdfpath, ".", recursive=TRUE)

    ## End(Not run)

[Package TargetSearch version 1.50.1 Index]