ursa_crop: Crop 'no data' margins.

ursa_cropR Documentation

Crop 'no data' margins.

Description

Function ursa_crop makes such spatial subset of source raster image, where margins of 'no data' values are absent or have specified width.

Usage



ursa_crop(obj, condition, border = 0, expand = 1, resetGrid = TRUE, verbose = FALSE)

Arguments

obj

Object of class ursaRaster

condition

Object of class ursaRaster or missing. The condition for cutting. If ‘missing’ then condition is defined from obj.

border

Integer of length 1, 2 or 4. Desired margins for geographical subset. Units are cells (pixels).

expand

Numeric of length 1, 2 or 4. Desired boundary expansion for geographical subset. Units is ratio (relative to 1). Default is 1.

resetGrid

Logical. If resetGrid=TRUE then sessional grid parameters is established from grid parameters of created raster. If resetGrid=FALSE then sessional grid parameters keep without change. Defailu is TRUE.

verbose

Logical. TRUE provides some additional information on console.

Details

This function calls regrid with passing values of arguments resetGrid and verbose without changes.

Bordering (argument border) is applied before expansion (argument expand).

This function is an instrument for data compression for spatial matrices with wide margins of 'no data' value. It keeps spatial structure (pixel's neighborhood) in the internal data storage. Otherwise, compress reduces object size using spatial indexing with dropping of spatial structure.

Value

Object of class ursaRaster

Author(s)

Nikita Platonov platonov@sevin.ru

Examples

session_grid(NULL)
'printCR' <- function(obj) print(with(ursa_grid(obj),c(c=columns,r=rows)))
g0 <- session_grid()
a <- pixelsize()
th <- with(ursa_grid(a),resx*resy*1e-6)
a0 <- a[a>th*0.9]
print(session_grid())
printCR(a0)
print(a0)
a1 <- ursa_crop(a0,resetGrid=TRUE)
print(session_grid())
printCR(a1)
print(a1)
a2 <- ursa_crop(a0,resetGrid=FALSE)
print(session_grid())
printCR(a2)
print(a2)
a3 <- a[a>=th*0.85 & a<=th*1.01]
b1 <- ursa_dummy(nband=3,min=0,max=255)
print(b1)
b2 <- ursa_crop(b1[a3>0],border=10)
print(b2)
printCR(b2)
b2[is.na(b2)] <- 255
display_rgb(b2)
b3 <- ursa_crop(b1,a3,border=0)
print(b3)
printCR(b3)

ursa documentation built on Sept. 30, 2024, 9:35 a.m.