Hi Tiago
I am using the pliman (latest version) to extract some features about the canopy of citrus plants (area, diameter, etc).
I imported the mosaic and shapefile (made in QGIS) into R without any problem. They are in the same CRS (coordinate reference system).
My mosaic (object orto) looks like this:
print(orto) # 3 camadas: R, G e B
class : SpatRaster
dimensions : 8317, 5725, 3 (nrow, ncol, nlyr)
resolution : 0.01999664, 0.01999765 (x, y)
extent : 252903.9, 253018.4, 7515062, 7515229 (xmin, xmax, ymin, ymax)
coord. ref. : WGS 84 / UTM zone 23S (EPSG:32723)
source : Ortomosaico-citrus-abril-2024.tif
names : red, green, blue
My shapefile (object parcelas) looks like this:
Simple feature collection with 373 features and 3 fields
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: 252926.2 ymin: 7515102 xmax: 252989.8 ymax: 7515189
Projected CRS: WGS 84 / UTM zone 23S
First 10 features:
fid id Genotype geometry
1 1 1 H4 POLYGON ((252926.7 7515189,...
2 2 2 H6 POLYGON ((252926.4 7515186,...
3 3 3 H10 POLYGON ((252926.4 7515183,...
4 4 4 H39 POLYGON ((252926.9 7515181,...
5 5 5 V3 POLYGON ((252927.1 7515178,...
6 6 6 V6 POLYGON ((252926.8 7515176,...
I am trying to analyze the mosaic with the code below:
mosaic_analyze(mosaic = orto,
r = 1, g = 2, b = 3,
shapefile = parcelas,
include_if = "centroid",
segment_individuals = TRUE,
segment_index = "NGRDI", threshold = 0.08, invert = FALSE,
watershed = TRUE)
However, the following error always happens:
Extracting data from block 1
Error in dplyr::select()
:
! Can't subset columns that don't exist.
✖ Column block
doesn't exist.
Run rlang::last_trace()
to see where the error occurred.
If I click on the last message about the error the following is shown:
rlang::last_trace()
<error/vctrs_error_subscript_oob>
Error in dplyr::select()
:
! Can't subset columns that don't exist.
✖ Column block
doesn't exist.
Backtrace:
▆
- └─pliman::mosaic_analyze(...)
- ├─dplyr::select(...)
- └─dplyr:::select.data.frame(...)
Run rlang::last_trace(drop = FALSE) to see 18 hidden frames.
rlang::last_trace(drop = FALSE)
<error/vctrs_error_subscript_oob>
Error in dplyr::select()
:
! Can't subset columns that don't exist.
✖ Column block
doesn't exist.
Backtrace:
▆
- ├─pliman::mosaic_analyze(...)
- │ ├─dplyr::select(...)
- │ └─dplyr:::select.data.frame(...)
- │ └─tidyselect::eval_select(expr(c(...)), data = .data, error_call = error_call)
- │ └─tidyselect:::eval_select_impl(...)
- │ ├─tidyselect:::with_subscript_errors(...)
- │ │ └─rlang::try_fetch(...)
- │ │ └─base::withCallingHandlers(...)
- │ └─tidyselect:::vars_select_eval(...)
- │ └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
- │ └─tidyselect:::eval_c(expr, data_mask, context_mask)
- │ └─tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
- │ └─tidyselect:::walk_data_tree(new, data_mask, context_mask)
- │ └─tidyselect:::as_indices_sel_impl(...)
- │ └─tidyselect:::as_indices_impl(...)
- │ └─tidyselect:::chr_as_locations(x, vars, call = call, arg = arg)
- │ └─vctrs::vec_as_location(...)
- └─vctrs (local)
<fn>
()
- └─vctrs:::stop_subscript_oob(...)
-
└─vctrs:::stop_subscript(...)
-
I was thinking that the problem shoud be my shapefile. So, I did a small example of shapefile (on the same mosaic) in plimanshiny and tried to run the same code with the "new" shapefile, but the error was shown again.
Helcio