inbo/reporting-rshiny-grofwildjacht

[BUG] Biotoop beschrijving & linked outputs not available for 2024

Opened this issue · 2 comments

Describe the bug
The Biotoop beschrijving & linked outputs like Aantal/100ha, Aantal/100ha bos & natuur, etc... are not advailable for 2024 this while WBE_habitats_2024.csv was uploaded succesfully.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'wbe-dev.inbo.be'
  2. Select a wbe (I chose De Zwarte Beek & Tussen Voer & Yse)
  3. Click on '2024'
  4. Scroll down to 'Biotoop beschrijving' or 'Evolutie gerapporteerd afschot '
  5. See error

Expected behavior
A Biotoop beschrijving graph is displayed like for other years.
Evolutie gerapporteerd afschot graphs are extended to 2024.

Screenshots
Biotoop beschrijving 2024
image
Biotoop beschrijving 2023
image

Evolutie gerapporteerd afschot - Aantal
image
Evolutie gerapporteerd afschot - Aantal/100ha
image
Evolutie gerapporteerd afschot - Aantal/100ha bos en natuur
image

Additional context
I've switched from sp to sf in calculating the habitat_lists so maybe a switchup of classes may be the cause.

Git SHA (after 0.3.1)
d6d14c6037ed6b3462988acbc0e282f4b8f0ae0f

I see the file WBE_habitats_2024.csv is in the bucket, but the file habitatData.RData that is read in the app was not updated:

> tmpTable[tmpTable$Key == "habitatData.RData", "LastModified"]
[1] "2023-11-27T11:20:28.000Z"

So, I tried to create the habitatData.RData using createHabitatData() from my side, with some hickups:

  • fbz_gemeentes_habitats.csv data has no region column, but the NISCODE. Therefore the data could not be matched to the spatial data. I have updated the code for this.
  • It looks like many regions are missing in fbz_gemeentes_habitats.csv. When comparing with the ones in spatialData, we have 150 missing:
> spatialData[[iRegion]]$NAAM[!spatialData[[iRegion]]$NAAM %in% tmpData$regio]
  [1] 3_NA                    2_NA                    4_NA                   
  [4] 8_NA                    7_NA                    9_NA                   
  [7] 5_NA                    10_NA                   6_Aartselaar           
 [10] 1_Koksijde              2_Knokke-Heist          6_Kapelle-op-den-Bos   
 [13] 2_Ardooie               7_Oud-Heverlee          2_Gent                 
 [16] 4_Gent                  6_Vilvoorde             4_Melle                
 [19] 3_Harelbeke             4_Affligem              5_Ranst                

(I have updated the code to ignore this for 'fbz_gemeentes' now).

@SanderDevisscher Can you check where/if the file habitatData.RData is updated at the backend?

I used the following code for this:

    bucket <- config::get("bucket", file = system.file("config.yml", package = "reportingGrofwild"))
    
    # List all available files on the S3 bucket
    tmpTable <- aws.s3::get_bucket_df(bucket = bucket)
    
    habitatFiles <- grep("habitats|wegdensiteit", tmpTable$Key, value = TRUE)
    for (iFile in habitatFiles)
      save_object(
        object = iFile, 
        bucket = bucket, 
        file = file.path(tempdir(), iFile)
      )
    
    createHabitatData(dataDir = tempdir(), bucket = bucket)

Ok makes sense the habitats are not updated using createHabitatData() in the backend. They're uploaded as is to the bucket. I'll implement the necessary changes.