readbin: Returns ".gz"-file as matrix or raster-object

View source: R/readbin.r

readbinR Documentation

Returns '.gz'-file as matrix or raster-object

Description

Returns '.gz'-file as matrix or raster-object.

Usage

readbin(filename, area, Image = F, byte = F, Raster = T)

Arguments

filename

Character string indicating search criteria for the '.gz'-file of interest. Only '.gz'-files with valid filenames can be read, consisting of:

area, source, parameter, resolution, timestep, date1, date2 and option-criteria, separated by an underscore with only option being aligned by a point and ending with '.gz', e.g.:

area_source_parameter_resolution_timestep_date1_date2.option.gz.

See region_definitions for valid area- and parameter_definitions for valid parameter-values, respecively.

Image

whether the a the '.gz'-file should be plotted immediately using image.plot-function of the fields-package (default is FALSE)

byte

whether the a the data of the '.gz'-file should be returned unconverted as a byte-values (default is FALSE)

Raster

whether the a the data of the '.gz'-file should be returned in a raster-object (default is TRUE)

area

Character string identifying the region that should be extracted. If missing, region is derived from the '.gz'-filename. See region_definitions for area definitions and use add.region to add new regions.

Author(s)

Robert K. Bauer

See Also

writebin, regions, crop, raster2matrix, param_convert

Examples

### Example: read and plot '.gz'-file
path <- system.file("test_files", package="oceanmap")
check_gzfiles(folder=path) # return file summary-table
gz.files <- Sys.glob(paste0(path,'/*.gz')) # load sample-'.gz'-files

### all manual:
obj <- readbin(gz.files[2],area='lion')
obj
ticks <- seq(20,30,5)
data('cmap')
image(obj,zlim=range(ticks),col=cmap$jet)
plotmap('lion',add=TRUE) # add landmask
#set.colorbar(ticks=ticks,cb.title='cb.title',cb.xlab='cb.xlab')

### using v:

## ticks set by adaptive.vals
v(obj,varname="sst2",cb.title='cb.title',cb.xlab='cb.xlab') 

## ticks set by parameter definition
v(obj,varname="sst2",cb.title='cb.title',cb.xlab='cb.xlab',adaptive.vals=FALSE) 

### extracting subregion:
obj <- readbin(gz.files[2])
area.extent <- extent(c(5,10,35,40))
subarea <- crop(obj,area.extent)
# v(subarea)

## getting average value:
mean(subarea[,],na.rm=TRUE)

oceanmap documentation built on Nov. 10, 2023, 5:08 p.m.

Related to readbin in oceanmap...