add.region | R Documentation |
adding a region to the region_definitions-file, taking or restoring a backup of region definitions. The basic idea is to provide a region-keyword that is used to access the region-information in later related function-calls (see: v and plotmap, regions). Information consists of a region-keyword, -longname, its spatial extent (longitudes and latitudes), grid resolution, as well as default colorbar position and figure size.
The required information can be provided by an interactive session (widget) that leads step by step through the region definition (is set default
), in parts by an extent-object with the missing information then completed by the session or by a one-row data frame that holds the entire information (see: region_definitions).
ATTENTION! When reinstalling or updating the oceanmap package, previous region definitions are getting lost! It is therefore highly recommanded to take and restore own backups (see: backup
and restore
).
add.region(add, add.px, cbx, cby, figdim, lib.folder,
widget=T, backup=F, backup.folder='.', backup.name, restore=F,backup.regions)
add |
extent-,raster-object or dataset containing all required region definition entries ( The values |
add.px |
dataframe or list containing region data needed to read gz-compressed |
cbx |
the horizontal limits (x1, x2) of the colorbar. If missing, the user will be asked for manual colorbar placement. |
cby |
the vertical limits (y1, y2) of the colorbar. If missing, the user will be asked for manual colorbar placement. |
figdim |
numeric vector indicating the |
lib.folder |
Character string indicating R-library path in which the oceanmap-package is installed. |
widget |
whether an interactive session (widget) shall assist the data entry procedure (default is |
backup |
whether the current region_definitions-file should be backuped in the folder ' |
backup.folder |
Character string indicating the folder where to store the region_definitions-file backup (default is the current working directory). |
backup.name |
Character string indicating the filename of the region_definitions-file backup (If |
restore |
whether to restore a backup of the region_definitions-file (default is |
backup.regions |
Vector of region indicators defining which regions should be saved in backup file. |
Robert K. Bauer
delete.region, region_definitions, regions, plotmap, v
## Example 1: Add region by supplying a one-row data.frame
## that holds the entire required information
# data(region_definitions) # load region_definitions
# lion <- region_definitions[region_definitions$label == 'lion',] # selecting Gulf of Lions region
# lion
# junk <- lion
# junk$label <- 'junk' # rename region label
# add.region(junk) # add junk region
# data(region_definitions) # reload region_definitions
# region_definitions[,1:9]
## Example 2: Delete region
#delete.region("junk") # delete junk region
#data(region_definitions) # reload region_definitions
#region_definitions[,1:9]
## Example 3: Add region by supplying an extent- or raster-object and running the widget
library(raster)
ext <- extent(0,10,50,60)
plotmap(ext)
#add.region(ext) # extent-object
r <- raster(ext)
#add.region(r) # raster-object
## Example 4: Add region by supplying raster-object, colorbar positions and running the widget
#add.region(r,cbx=c(5,9.5),cby=c(51.7,52.4))
## Example 5: Add region by running the widget
#add.region()
## Example 6: Add region by running the widget
#add.region(add.px=list(label="lion",nrow=10,ncol=10))
#data(region_definitions)
#region_definitions[region_definitions$label =="lion",]
## Example 7: Creating a backup
#add.region(backup=T)
#add.region(backup=T, backup.folder=".",backup.regions=c("lion","medw4"))
## Example 8: Restoring the backup of the original region_definitions file
#add.region(restore=T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.