Skip to content

Commit

Permalink
Merge pull request #1132 from M3nin0/hotfix/args-merge
Browse files Browse the repository at this point in the history
hotfix: fix sits_regularize and sits_merge
  • Loading branch information
OldLipe committed May 22, 2024
2 parents 745a00f + dd05607 commit 112cbe4
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 24 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: sits
Type: Package
Version: 1.5.1
Version: 1.5.0-1
Title: Satellite Image Time Series Analysis for Earth Observation Data Cubes
Authors@R: c(person('Rolf', 'Simoes', role = c('aut'), email = '[email protected]'),
person('Gilberto', 'Camara', role = c('aut', 'cre'), email = '[email protected]'),
Expand All @@ -17,7 +17,7 @@ Description: An end-to-end toolkit for land use and land cover classification
applied to satellite image data cubes, as described in Simoes et al (2021) <doi:10.3390/rs13132428>.
Builds regular data cubes from collections in AWS, Microsoft Planetary Computer,
Brazil Data Cube, and Digital Earth Africa using the Spatio-temporal Asset Catalog (STAC)
protocol (<https://stacspec.org/> and the 'gdalcubes' R package
protocol (<https://stacspec.org/>) and the 'gdalcubes' R package
developed by Appel and Pebesma (2019) <doi:10.3390/data4030092>.
Supports visualization methods for images and time series and
smoothing filters for dealing with noisy time series.
Expand Down
6 changes: 0 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,6 @@ S3method(sits_cube,default)
S3method(sits_cube,local_cube)
S3method(sits_cube,sar_cube)
S3method(sits_cube,stac_cube)
S3method(sits_detect_change,default)
S3method(sits_detect_change,raster_cube)
S3method(sits_detect_change,sits)
S3method(sits_get_data,csv)
S3method(sits_get_data,data.frame)
S3method(sits_get_data,default)
Expand Down Expand Up @@ -443,9 +440,6 @@ export(sits_config)
export(sits_config_show)
export(sits_cube)
export(sits_cube_copy)
export(sits_detect_change)
export(sits_detect_change_method)
export(sits_dtw)
export(sits_factory_function)
export(sits_filter)
export(sits_formula_linear)
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# SITS Release History

# What's new in SITS version 1.5

### Hotfix version 1.5.0-1
* 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 date parameter usage in `sits_view()`
* Improve `plot()` performance using raster overviews
* Include support for PLANET Mosaic product

### New features in SITS version 1.5.0
* Support for SENTINEL-1-RTC and SENTINEL-2-L2A in CDSE
* Include support for DEA products SENTINEL-1-RTC, LS5-SR, LS7-SR, LS9-SR, ALOS-PALSAR-MOSAIC, NDVI ANOMALY, DAILY CHIRPS, MONTHLY CHIRPS and DEM-30
Expand Down
4 changes: 2 additions & 2 deletions R/api_detect_changes.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
# Fill with zeros remaining NA pixels
values <- C_fill_na(values, 0)
# Used to check values (below)
n_input_pixels <- nrow(values)
input_pixels <- nrow(values)
# Include names in cube predictors
colnames(values) <- .pred_features_name(
.ml_bands(cd_method), tile_timeline
Expand All @@ -163,7 +163,7 @@
# Are the results consistent with the data input?
.check_processed_values(
values = values,
n_input_pixels = n_input_pixels
input_pixels = input_pixels
)
# Log here
.debug_log(
Expand Down
2 changes: 1 addition & 1 deletion R/api_regularize.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
breaks = timeline,
labels = FALSE
)
fi_groups <- unname(tapply(fi, groups, list))
fi_groups <- unname(split(fi, groups))
assets <- .common_size(
.discard(tile, "file_info"),
feature = timeline[unique(groups)],
Expand Down
4 changes: 0 additions & 4 deletions R/sits_detect_change.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#' each point (tibble of class "sits")
#' or a data cube indicating detections in each pixel
#' (tibble of class "detections_cube").
#' @export
sits_detect_change <- function(data,
cd_method,
...,
Expand All @@ -49,7 +48,6 @@ sits_detect_change <- function(data,
}

#' @rdname sits_detect_change
#' @export
sits_detect_change.sits <- function(data,
cd_method,
...,
Expand All @@ -74,7 +72,6 @@ sits_detect_change.sits <- function(data,
}

#' @rdname sits_detect_change
#' @export
sits_detect_change.raster_cube <- function(data,
cd_method, ...,
roi = NULL,
Expand Down Expand Up @@ -180,7 +177,6 @@ sits_detect_change.raster_cube <- function(data,
}

#' @rdname sits_detect_change
#' @export
sits_detect_change.default <- function(data, cd_method, ...) {
stop("Input should be a sits tibble or a data cube")
}
2 changes: 0 additions & 2 deletions R/sits_detect_change_method.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#' @return Change detection method prepared
#' to be passed to
#' \code{\link[sits]{sits_detect_change}}
#' @export
#'
sits_detect_change_method <- function(samples, cd_method = sits_dtw()) {
# set caller to show in errors
.check_set_caller("sits_detect_change_method")
Expand Down
2 changes: 0 additions & 2 deletions R/sits_dtw.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#' used in operations with data cubes.
#' @return Change detection method prepared to be passed to
#' \code{\link[sits]{sits_detect_change_method}}
#' @export
#'
sits_dtw <-
function(samples = NULL,
...,
Expand Down
10 changes: 5 additions & 5 deletions R/sits_merge.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ sits_merge.raster_cube <- function(data1, data2, ...) {
.data[["tile"]]
)

if (inherits(data2, "raster_cube")) {
return(.merge_equal_cube(data1, data2))
} else {
if (inherits(data2, "sar_cube")) {
return(.merge_distinct_cube(data1, data2))
} else {
return(.merge_equal_cube(data1, data2))
}
}

Expand All @@ -152,8 +152,8 @@ sits_merge.raster_cube <- function(data1, data2, ...) {

.merge_distinct_cube <- function(data1, data2) {
# Get cubes timeline
d1_tl <- unique(as.Date(unlist(.cube_timeline(data1))))
d2_tl <- unique(as.Date(unlist(.cube_timeline(data2))))
d1_tl <- unique(as.Date(.cube_timeline(data1)[[1]]))
d2_tl <- unique(as.Date(.cube_timeline(data2)[[1]]))

# get intervals
d1_period <- as.numeric(
Expand Down
30 changes: 30 additions & 0 deletions inst/extdata/sources/config_source_planet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
sources:
PLANET :
s3_class : ["planet_cube", "stac_cube", "eo_cube",
"raster_cube"]
collections :
MOSAIC :
bands :
B01 : &planet_mosaic_4m
missing_value : 0
minimum_value : 1
maximum_value : 65534
scale_factor : 0.01
offset_value : 0
resolution : 4.77
band_name : "blue"
data_type : "INT2U"
B02 :
<<: *planet_mosaic_4m
band_name : "green"
B03 :
<<: *planet_mosaic_4m
band_name : "red"
B04 :
<<: *planet_mosaic_4m
band_name : "nir"
satellite : "PLANETSCOPE"
sensor : "MOSAIC"
collection_name: "planet-mosaic"
ext_tolerance: 0
grid_system : ""

0 comments on commit 112cbe4

Please sign in to comment.