get_iso_polys {CCAMLRGIS}R Documentation

Generate contour polygons from raster

Description

From an input raster and chosen cuts (classes), turns areas between contours into polygons. An input polygon may optionally be given to constrain boundaries. The accuracy is dependent on the resolution of the raster (e.g., see load_Bathy to get high resolution bathymetry).

Usage

get_iso_polys(
  Rast,
  Poly = NULL,
  Cuts,
  Cols = c("green", "yellow", "red"),
  Grp = FALSE,
  strict = TRUE
)

Arguments

Rast

raster with the appropriate projection, such as SmallBathy. It is recommended to use a raster of higher resolution (see load_Bathy).

Poly

optional, single polygon inside which contour polygons will be generated. May be created using create_Polys or by subsetting an object obtained using one of the load_ functions.

Cuts

numeric, vector of desired contours. For example, Cuts=c(-2000,-1000,-500).

Cols

character, vector of desired colors (see add_col).

Grp

logical (TRUE/FALSE), if set to TRUE (slower), contour polygons that touch each other are identified and grouped (a Grp column is added to the object). This can be used, for example, to identify seamounts that are constituted of several isobaths.

strict

logical (TRUE/FALSE), if set to TRUE (default) polygons are created only between the chosen Cuts. If set to FALSE, extra polygons are created beyond the bounds of Cuts.

Value

Spatial object in your environment. Data within the resulting object contains a polygon in each row. Columns are as follows: ID is a unique polygon identifier; Iso is a contour polygon identifier; Min and Max are the range of contour values; c is the color of each contour polygon; if Grp was set to TRUE, additional columns are: Grp is a group identifier (e.g., a seamount constituted of several isobaths); AreaKm2 is the polygon area in square kilometers; Labx and Laby can be used to label groups (see GitHub example).

See Also

load_Bathy, create_Polys, get_depths.

Examples


# For more examples, see:
# https://github.com/ccamlr/CCAMLRGIS#46-get_iso_polys

Poly=create_Polys(Input=data.frame(ID=1,Lat=c(-55,-55,-61,-61),Lon=c(-30,-25,-25,-30)))
IsoPols=get_iso_polys(Rast=SmallBathy(),Poly=Poly,Cuts=seq(-8000,0,length.out=10),Cols=rainbow(9))

plot(st_geometry(Poly))
plot(st_geometry(IsoPols),col=IsoPols$c,add=TRUE) 



[Package CCAMLRGIS version 4.1.1 Index]