HOPE-UIB-BIO / FOSSILPOL-issues

Repository created to manage Issues for FOSSILPOL and R-Fossilpol-package
https://hope-uib-bio.github.io/FOSSILPOL-website/
0 stars 0 forks source link

var name "region" from the shapefile "Regions" in the input data from the workflow, is not being recognized #25

Closed christianqz closed 7 months ago

christianqz commented 8 months ago

var name "region" from the shapefile "Regions" in the input data from the workflow, is not being recognized

In the Merge_datasets.R section in the line :

data_geo <-
  RFossilpol::geo_assign_by_list(
    data_source = data_sorted,
    dir = current_dir, # [config criteria]
    optional_info_to_assign = optional_info_to_assign
  )

I get the following message:

✖ WARNING: Selected file does not contains value: region

For the "optional_info_to_assign", I used the shapefile folder "Regions_shapefile" from the Data input of the workflow. It seems to recognize everything except the var name and I tried using "REGION", "Region" for variable but none of them is being recognized. I opened ARCGIS to actually see the right spelling and it looks like it is just "region" . But when I run the example of biomes, I dont have any problem. I have to say, I switch: sf::sf_use_s2(FALSE) before running the code.

To Reproduce

  1. Run script
    
    > optional_info_to_assign <-
    +     tibble::tribble(
    +         ~var_name, ~sel_method, ~dir, ~file_name, ~var,"regions","shapefile", paste0(current_dir, "/Data/Input/Spatial/Regions_shapefile"),"Regions","region")

data_geo <- RFossilpol::geo_assign_by_list( data_source = data_sorted, dir = current_dir, # [config criteria] optional_info_to_assign = optional_info_to_assign )


**Screenshots**

![error](https://github.com/HOPE-UIB-BIO/FOSSILPOL-issues/assets/8486679/5ee37f08-2047-460f-ac14-a2545bb51c68)
![arcgis](https://github.com/HOPE-UIB-BIO/FOSSILPOL-issues/assets/8486679/e730b167-b16f-448f-a2df-bcb24d88795d)

 -  Windows 10
 - Workflow Version 1.0.1
 - RFossilpol package 1.0.0
OndrejMottl commented 7 months ago

Hi @christianqz. it seems that it is not an issue of the function but of the data. From the error message from your screenshot, there is already a column "region" (19th column) in the data data_sorted. The function is trying to assign "region" again but duplicated names are not allowed, therefore, it will rename it, which will invalidate the check for successful assign of "region.

You should check why your data already has a column named "region" but there is a simple workaround:

data_geo <-
  data_sorted %>%
  dplyr::select(-region) %>% 
  RFossilpol::geo_assign_by_list(
    data_source = .,
    dir = current_dir, # [config criteria]
    optional_info_to_assign = optional_info_to_assign
  )
christianqz commented 7 months ago

Thank you Ondrej! I also used a different shapefile and saved it in the Input - spatial data, and worked perfectly after that