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

Description Usage Arguments Author(s) See Also Examples

View source: R/readbin.r

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
### 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 March 23, 2020, 5:06 p.m.

Related to readbin in oceanmap...