inbo / reporting-rshiny-grofwildjacht

Rshiny app for grofwildjacht
https://grofwildjacht.inbo.be/
MIT License
1 stars 1 forks source link

[BUG] data download from kencijfers table incorrect #458

Closed SanderDevisscher closed 4 months ago

SanderDevisscher commented 6 months ago

Describe the bug When downloading data from the kencijfers table (dashboard > populatie > Tabel kencijfers) for the year 2020 you get a lot of 1's and some 2s but nothing higher in both observations & animal shot. While according to the map there are communes with more boars shot. for example in Beringen there were 148 boars shot in 2020. When looking at the data for other years then 2020 the downloaded data seems ok. I've not done a in depth investigation.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'faunabeheer.inbo.be'
  2. Click on 'dashbaord'
  3. Set "Limburg & Antwerpen" as region
  4. Select "Kencijfers Tabel"
  5. Scroll down to "Kencijfers Tabel"
  6. click "download data"
  7. open data
  8. See error

Expected behavior a csv is downloaded with correct number of individuals shot/observed for the selected year

mvarewyck commented 5 months ago

It occurs when the selected dataset contains municipalities which are assigned to different provinces. I've now updated the code such that it no longer takes the length but sum of 'aantal' in that case. This was the reason that reported numbers were so small (length instead of sum).

@SanderDevisscher Ideally this should be also fixed in the data at the back-end. E.g. in 2020 I found

# file "rshiny_reporting_data_geography_processed.parquet"
geoData <- loadRawData(type = "geo")
subGeoData <- unique(geoData[!is.na(geoData$gemeente_afschot_locatie) & geoData$afschotjaar == 2020 & geoData$provincie %in% c("Limburg", "Antwerpen"), c("gemeente_afschot_locatie", "provincie")])
selectGemeentes <- which(duplicated(subGeoData$gemeente_afschot_locatie))
subGeoData[subGeoData$gemeente_afschot_locatie %in% subGeoData$gemeente_afschot_locatie[selectGemeentes], ]
# # A tibble: 4 × 2
#   gemeente_afschot_locatie provincie
#   <chr>                    <fct>    
# 1 Lommel                   Limburg  
# 2 Tessenderlo              Limburg  
# 3 Tessenderlo              Antwerpen
# 4 Lommel                   Antwerpen
SanderDevisscher commented 5 months ago

hmm this issue has been fixed in the backoffice but it hasn't been deployed yet see https://github.com/inbo/reporting-rshiny-grofwildjacht/issues/456#issuecomment-1980772005.