Skip to content

Commit

Permalink
plot overviews
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertocamara committed May 19, 2024
1 parent 61af7d9 commit 7e98e88
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 115 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ Description: An end-to-end toolkit for land use and land cover classification
temporal convolutional neural networks proposed by Pelletier et al (2019) <doi:10.3390/rs11050523>,
residual networks by Fawaz et al (2019) <doi:10.1007/s10618-019-00619-1>, and temporal attention encoders
by Garnot and Landrieu (2020) <doi:10.48550/arXiv.2007.00586>.
Supports GPU processing of deep learning models using torch <https://torch.mlverse.org/>.
Performs efficient classification of big Earth observation data cubes and includes
functions for post-classification smoothing based on Bayesian inference, and
methods for uncertainty assessment. Enables best
practices for estimating area and assessing accuracy of land change as
methods for active learning and uncertainty assessment. Supports object-based
time series analysis using package supercells <https://jakubnowosad.com/supercells/>.
Enables best practices for estimating area and assessing accuracy of land change as
recommended by Olofsson et al (2014) <doi:10.1016/j.rse.2014.02.015>.
Minimum recommended requirements: 16 GB RAM and 4 CPU dual-core.
Encoding: UTF-8
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ S3method(.view_add_overlay_grps,class_cube)
S3method(.view_add_overlay_grps,derived_cube)
S3method(.view_add_overlay_grps,raster_cube)
S3method(.view_add_overlay_grps,vector_cube)
S3method(.view_adjust_palette,default)
S3method(.view_adjust_palette,sar_cube)
S3method(plot,class_cube)
S3method(plot,class_vector_cube)
S3method(plot,geo_distances)
Expand Down
26 changes: 17 additions & 9 deletions R/api_gdal.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,30 @@
)
return(invisible(file))
}
#' @title Run gdal_warp for SAR GRD files
#' @title Run gdal_warp_file
#' @noRd
#' @param raster_file File to be copied from (with path)
#' @param size Size of output file
#' @param sizes Sizes of output file
#' @param t_srs Target spatial reference system
#' @returns Name of output file
.gdal_warp_grd <- function(raster_file, size) {
.gdal_warp_file <- function(raster_file, sizes, t_srs = NULL) {
# create a temporary file
temp_file <- tempfile(fileext = ".tif")
# basic parameters
params = list(
"-ts" = list(sizes[["xsize"]], sizes[["ysize"]]),
"-multi" = FALSE,
"-q" = TRUE,
"-overwrite" = FALSE
)
# additional param for target SRS
if (.has(t_srs))
params <- append(params, c("t_srs" = t_srs))
# warp the data
.gdal_warp(
file = temp_file,
base_files = raster_file,
params = list(
"-ts" = list(size[["xsize"]], size[["ysize"]]),
"-multi" = FALSE,
"-q" = TRUE,
"-overwrite" = FALSE
),
params = params,
quiet = TRUE)
return(temp_file)
}
Expand Down
14 changes: 7 additions & 7 deletions R/api_plot_raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
band_offset <- .offset(band_conf)
max_value <- .max_value(band_conf)
# retrieve the overview if COG
bw_file <- .gdal_warp_grd(bw_file, sizes)
bw_file <- .gdal_warp_file(bw_file, sizes)
# open the file in terra
rast <- terra::rast(bw_file)
# apply scale and offset
Expand Down Expand Up @@ -142,9 +142,9 @@
max_value <- .max_value(band_params)
# used for SAR images without tiling system
if (tile[["tile"]] == "NoTilingSystem") {
red_file <- .gdal_warp_grd(red_file, sizes)
green_file <- .gdal_warp_grd(green_file, sizes)
blue_file <- .gdal_warp_grd(blue_file, sizes)
red_file <- .gdal_warp_file(red_file, sizes)
green_file <- .gdal_warp_file(green_file, sizes)
blue_file <- .gdal_warp_file(blue_file, sizes)
}
# plot multitemporal band as RGB
p <- .plot_rgb_stars(
Expand Down Expand Up @@ -201,9 +201,9 @@
sizes <- .tile_overview_size(tile = tile, max_size)
# used for SAR images
if (tile[["tile"]] == "NoTilingSystem") {
red_file <- .gdal_warp_grd(red_file, sizes)
green_file <- .gdal_warp_grd(green_file, sizes)
blue_file <- .gdal_warp_grd(blue_file, sizes)
red_file <- .gdal_warp_file(red_file, sizes)
green_file <- .gdal_warp_file(green_file, sizes)
blue_file <- .gdal_warp_file(blue_file, sizes)
}
p <- .plot_rgb_stars(
red_file = red_file,
Expand Down
Loading

0 comments on commit 7e98e88

Please sign in to comment.