Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Bug with the function "mosaic_analyze" when the argument "segment_individuals = TRUE" #16

@HelcioDuartePereira

Description

@HelcioDuartePereira

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:

  1. └─pliman::mosaic_analyze(...)
  2. ├─dplyr::select(...)
  3. └─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:

  1. ├─pliman::mosaic_analyze(...)
  2. │ ├─dplyr::select(...)
  3. │ └─dplyr:::select.data.frame(...)
  4. │ └─tidyselect::eval_select(expr(c(...)), data = .data, error_call = error_call)
  5. │ └─tidyselect:::eval_select_impl(...)
  6. │ ├─tidyselect:::with_subscript_errors(...)
  7. │ │ └─rlang::try_fetch(...)
  8. │ │ └─base::withCallingHandlers(...)
  9. │ └─tidyselect:::vars_select_eval(...)
  10. │ └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
  11. │ └─tidyselect:::eval_c(expr, data_mask, context_mask)
  12. │ └─tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
  13. │ └─tidyselect:::walk_data_tree(new, data_mask, context_mask)
  14. │ └─tidyselect:::as_indices_sel_impl(...)
  15. │ └─tidyselect:::as_indices_impl(...)
  16. │ └─tidyselect:::chr_as_locations(x, vars, call = call, arg = arg)
  17. │ └─vctrs::vec_as_location(...)
  18. └─vctrs (local) <fn>()
  19. └─vctrs:::stop_subscript_oob(...)
  20. └─vctrs:::stop_subscript(...)
    
  21.   └─rlang::abort(...)
    

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions