Skip to content

Commit

Permalink
fix conflict merge
Browse files Browse the repository at this point in the history
  • Loading branch information
M3nin0 committed Aug 15, 2024
2 parents 3632ce1 + 687f423 commit 8be2653
Show file tree
Hide file tree
Showing 54 changed files with 690 additions and 1,886 deletions.
8 changes: 2 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Suggests:
RcppArmadillo (>= 0.12),
scales,
spdep,
stars (>= 0.6),
stars (>= 0.6-5),
stringr,
supercells (>= 1.0.0),
testthat (>= 3.1.3),
Expand Down Expand Up @@ -137,9 +137,7 @@ Collate:
'api_cube.R'
'api_data.R'
'api_debug.R'
'api_detect_changes.R'
'api_download.R'
'api_dtw.R'
'api_environment.R'
'api_factory.R'
'api_file_info.R'
Expand Down Expand Up @@ -202,6 +200,7 @@ Collate:
'api_tile.R'
'api_timeline.R'
'api_tmap.R'
'api_tmap_v3.R'
'api_torch.R'
'api_torch_psetae.R'
'api_ts.R'
Expand Down Expand Up @@ -231,9 +230,6 @@ Collate:
'sits_cube_copy.R'
'sits_clean.R'
'sits_cluster.R'
'sits_detect_change.R'
'sits_detect_change_method.R'
'sits_dtw.R'
'sits_factory.R'
'sits_filters.R'
'sits_geo_dist.R'
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ S3method("sits_labels<-",class_cube)
S3method("sits_labels<-",default)
S3method("sits_labels<-",probs_cube)
S3method("sits_labels<-",sits)
S3method(.accuracy_get_validation,csv)
S3method(.accuracy_get_validation,data.frame)
S3method(.accuracy_get_validation,gpkg)
S3method(.accuracy_get_validation,sf)
S3method(.accuracy_get_validation,shp)
S3method(.band_rename,raster_cube)
S3method(.band_rename,sits)
S3method(.check_samples,default)
Expand Down
17 changes: 13 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# SITS Release History

# What's new in SITS version 1.5

### Hotfix version 1.5.0-1
# What's new in SITS version 1.5.1

* Support for ESA World Cover map
* Support for many Digital Earth Australia products
* Support for Digital Earth Africa geomedian products
* Improve .netrc access to Harmonized Landsat-Sentinel cubes
* Use ROI to cut data cube after mosaic operation
* Support for raster and vector classification using DEM as base cubes
* Convert from 'httr' package to 'httr2' package
* Remove deprecated class to purrr::map_dfc, purrr::map_dfr and similar
* Fix tuning for torch models
* Add geometry validation when extracting time series
* Add multicores processing support for active learning sampling methods
* Remove tapply from `.reg_cube_split_assets()` for R 4.X compatibility
* Fix `sits_merge()` function that was not merging `SAR` and `OPTICAL` cubes
* Rename n_input_pixels back to input_pixels for compatibility with models trained in old versions of the package
* Fix torch usage in Apple M3 by turning off MPS technology
* Fix torch usage in Apple M3
* Fix date parameter usage in `sits_view()`
* Improve `plot()` performance using raster overviews
* Include support for PLANET Mosaic product
Expand Down
68 changes: 68 additions & 0 deletions R/api_accuracy.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,71 @@
)
)
}
#' @title Get validation samples
#' @name .accuracy_get_validation
#' @description Retrieves and checks validation data
#' @keywords internal
#' @noRd
#' @param validation validation (CSV file, SHP file, SF object, data.frame)
#' @return samples for validation
#'
.accuracy_get_validation <- function(validation){
# handle validation data as files
if (is.character(validation)) {
val_class <- tolower(.file_ext(validation))
class(validation) <- c(val_class, validation)
}
UseMethod(".accuracy_get_validation", validation)
}
#' @export
.accuracy_get_validation.csv <- function(validation){
# Read sample information from CSV file and put it in a tibble
valid_samples <- .csv_get_validation_samples(validation)
return(valid_samples)
}
#' @export
.accuracy_get_validation.shp <- function(validation){
validation_sf <- sf::st_read(validation)
.check_that(all(sf::st_geometry_type(validation_sf) == "POINT"))
valid_samples <- .accuracy_get_validation(validation_sf)
return(valid_samples)
}
#' @export
.accuracy_get_validation.gpkg <- function(validation){
validation_sf <- sf::st_read(validation)
.check_that(all(sf::st_geometry_type(validation_sf) == "POINT"))
valid_samples <- .accuracy_get_validation(validation_sf)
return(valid_samples)
}
#' @export
.accuracy_get_validation.sf <- function(validation){
# Pre-condition - check for the required columns
.check_chr_contains(colnames(validation), c("label"))
# transform the `sf` object in a valid
valid_samples <- validation |>
dplyr::mutate(
geom = sf::st_geometry(validation)
) |>
dplyr::mutate(
geom = sf::st_centroid(.data[["geom"]])
) |>
dplyr::mutate(
coords = sf::st_coordinates(.data[["geom"]])
) |>
dplyr::mutate(
longitude = .data[["coords"]][, 1],
latitude = .data[["coords"]][, 2]
) |>
dplyr::select(
"label", "longitude", "latitude"
)
return(valid_samples)
}
#' @export
`.accuracy_get_validation.data.frame` <- function(validation){
# handle data frames
.check_chr_contains(colnames(validation),
c("label", "longitude", "latitude")
)
return(validation)
}
27 changes: 27 additions & 0 deletions R/api_csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,30 @@
class(samples) <- c("sits", class(samples))
return(samples)
}

#' @title Transform a CSV with labelled points for accuracy assessmentinto a samples file
#' @name .csv_get_validation_samples
#' @author Gilberto Camara
#' @keywords internal
#' @noRd
#' @param csv_file CSV that describes the data to be retrieved.
#' @return A tibble with information the samples to be retrieved
#'
.csv_get_validation_samples <- function(csv_file) {
# read sample information from CSV file and put it in a tibble
samples <- tibble::as_tibble(
utils::read.csv(
file = csv_file,
stringsAsFactors = FALSE
)
)
# pre-condition - check if CSV file is correct
.check_samples(samples)
# select valid columns
samples <- dplyr::select(
samples,
c("longitude", "latitude", "label")
)
class(samples) <- c("sits", class(samples))
return(samples)
}
2 changes: 2 additions & 0 deletions R/api_samples.R
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@
dplyr::filter(.data[["label"]] == lab) |>
dplyr::slice_sample(n = samples_label)
})
# transform to sf object
samples <- sf::st_as_sf(samples)

return(samples)
}
Expand Down
Loading

0 comments on commit 8be2653

Please sign in to comment.