Description Usage Arguments Value Examples
sobel takes a multi-band raster stack, conducts principal components analysis, then applies a Sobel filter to n retained PCA axes and appends these n bands to the tile.
1 |
tile |
File path to a mulit-band raster stack. |
axes |
How many PCA axes to retain and filter. |
fill_na |
Whether to impute NA cells with mean of neighboring cells. |
None. Appends n bands to tile and overwrites appended stack to tile file path.
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 31 32 33 34 35 36 37 38 | library(paint2train)
image_dir <- tempfile()
image_url <- 'https://storage.googleapis.com/mpgranch_data/sample_4band.tif'
download.file(url = image_url, destfile = image_dir)
tdir <- tempdir()
setwd(tdir)
preproc_dir <- 'preproc_tiles'
dir.create(preproc_dir)
#some test coordinates
xcoords <- c(727495,
727919)
ycoords <- c(5175339,
5175408)
coord_mat <- cbind(xcoords, ycoords)
ls <- 30 #how big should the tiles be, this is the side length (in units of data, meters here)
buff <- 5 #buffer in native units of CRS
cores <- ifelse(.Platform$OS.type == 'unix', #how many cores to use for preprocessing
parallel::detectCores() - 1,
1)
tile_at_coords(coords = coord_mat,
len_side = ls,
buffer = buff,
out_dir = preproc_dir,
img = image_dir,
ncores = cores)
t <- list.files(preproc_dir, full.names = TRUE)[1]
ndvi_msavi(tile = t, r_band = 1, nir_band = 4)
sobel(t, axes = 3, fill_na = TRUE)
t_sobels <- stack(t)[[7:9]]
names(t_sobels) <- c('PC1','PC2','PC3')
plot(t_sobels, col = gray.colors(100))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.