@@ -160,7 +160,7 @@ test_that("Creating cubes from BDC - CBERS-WFI-8D", {
160
160
cube_nrows <- .tile_nrows(cbers_cube_8d )
161
161
expect_true(.raster_nrows(r_obj ) == cube_nrows )
162
162
})
163
- test_that(" Creating cubes from BDC - based on ROI with shapefile " , {
163
+ test_that(" Creating cubes from BDC - based on ROI using sf obejct " , {
164
164
shp_file <- system.file(
165
165
" extdata/shapefiles/mato_grosso/mt.shp" ,
166
166
package = " sits"
@@ -218,6 +218,44 @@ test_that("Creating cubes from BDC - based on ROI with shapefile", {
218
218
tile_011009 <- .cube_filter_tiles(modis_cube , " 011009" )
219
219
expect_equal(nrow(tile_011009 ), 1 )
220
220
221
+ })
222
+ test_that(" Creating cubes from BDC - based on ROI using shapefile" , {
223
+ shp_file <- system.file(
224
+ " extdata/shapefiles/mato_grosso/mt.shp" ,
225
+ package = " sits"
226
+ )
227
+ # create a raster cube file based on the information about the files
228
+ modis_cube <- .try(
229
+ {
230
+ sits_cube(
231
+ source = " BDC" ,
232
+ collection = " MOD13Q1-6" ,
233
+ bands = c(" NDVI" , " EVI" ),
234
+ roi = shp_file ,
235
+ start_date = " 2018-09-01" ,
236
+ end_date = " 2019-08-29" ,
237
+ progress = FALSE
238
+ )
239
+ },
240
+ .default = NULL
241
+ )
242
+ testthat :: skip_if(purrr :: is_null(modis_cube ),
243
+ message = " BDC is not accessible"
244
+ )
245
+ expect_true(all(sits_bands(modis_cube ) %in% c(" NDVI" , " EVI" )))
246
+ bbox <- sits_bbox(modis_cube , as_crs = " EPSG:4326" )
247
+ sf_mt <- sf :: read_sf(shp_file )
248
+ bbox_shp <- sf :: st_bbox(sf_mt )
249
+ expect_lt(bbox [" xmin" ], bbox_shp [" xmin" ])
250
+ expect_lt(bbox [" ymin" ], bbox_shp [" ymin" ])
251
+ expect_gt(bbox [" xmax" ], bbox_shp [" xmax" ])
252
+ expect_gt(bbox [" ymax" ], bbox_shp [" ymax" ])
253
+ intersects <- .cube_intersects(modis_cube , sf_mt )
254
+ expect_true(all(intersects ))
255
+
256
+ tile_011009 <- .cube_filter_tiles(modis_cube , " 011009" )
257
+ expect_equal(nrow(tile_011009 ), 1 )
258
+
221
259
})
222
260
test_that(" Creating cubes from BDC - invalid roi" , {
223
261
expect_error(
@@ -531,18 +569,17 @@ test_that("Creating Sentinel cubes from MPC with ROI", {
531
569
expect_true(.raster_nrows(r_obj ) == cube_nrows )
532
570
})
533
571
test_that(" Creating Sentinel-1 RTC cubes from MPC" , {
534
- roi <- sits_mgrs_to_roi(" 20LKP" )
535
572
cube_s1_rtc <- sits_cube(
536
573
source = " MPC" ,
537
574
collection = " SENTINEL-1-RTC" ,
538
575
bands = c(" VV" , " VH" ),
539
576
orbit = " descending" ,
540
- roi = roi ,
541
- start_date = " 2023 -03-01" ,
542
- end_date = " 2023 -09-30"
577
+ tiles = c( " 24MUS " , " 24MVS " ) ,
578
+ start_date = " 2021 -03-01" ,
579
+ end_date = " 2021 -09-30"
543
580
)
544
581
bbox <- sits_bbox(cube_s1_rtc )
545
- expect_true(grepl( " 18N " , bbox [[" crs" ]]) )
582
+ expect_equal( " EPSG:4326 " , bbox [[" crs" ]])
546
583
expect_equal(381340 , bbox [[" xmin" ]])
547
584
expect_equal(701860 , bbox [[" xmax" ]])
548
585
0 commit comments