inbo / reporting-rshiny-grofwildjacht

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

[BUG] Afschotlocations for specific municipalities are sometimes assigned to different (wrong) provinces #456

Closed mvarewyck closed 6 months ago

mvarewyck commented 6 months ago

To Reproduce

For example for 'Lommel' for some records, the assigned province is Limburg while for others it is Antwerpen.

library(reportingGrofwild)
geoData <- loadRawData(type = "geo")

table(geoData[geoData$gemeente_afschot_locatie == "Lommel", "provincie"])
# provincie
# West-Vlaanderen Oost-Vlaanderen  Vlaams Brabant       Antwerpen         Limburg 
#               0               0               0              14            2718 
#          Voeren        Onbekend 
#               0               0 

subData <- geoData[geoData$gemeente_afschot_locatie == "Lommel", ]
xtabs(~ subData$provincie + subData$afschotjaar, drop.unused.levels = TRUE)
#                  subData$afschotjaar
# subData$provincie 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013
#         Antwerpen    0    0    0    0    0    0    0    0    0    0    0    0
#         Limburg     24   91   79   87   78   75   75   83  131  121  107  114
#                  subData$afschotjaar
# subData$provincie 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024
#         Antwerpen    0    0    4    2    6    0    1    1    0    0    0
#         Limburg     33  104  131  135  185  186  187  218  216  255    3

subData$ID[subData$provincie %in% "Antwerpen"]
#  [1] "acb55f06-e64e-42c0-a818-36540efceb8a"
#  [2] "d910b347-5a7f-425e-a515-4cf2f8ecb4f0"
#  [3] "a13fd62a-63ad-441f-9c11-8a88217896a5"
#  [4] "2b7daffe-985c-4450-b261-ff717ae09e20"
#  [5] "8aadf1b0-127d-46fd-a888-b1309d20aa16"
#  [6] "d534c58b-5cf9-4dda-a611-6834191fb1f9"
#  [7] "0253f2ce-f0a8-4a85-babd-d5a5ead4ca43"
#  [8] "25e30a5f-c09b-4b7b-8026-0707cd14c5c9"
#  [9] "09f5142f-9834-42a2-943f-1508d0b547c5"
# [10] "c84de6a9-3027-48c6-937c-c0d2c7475ab7"
# [11] "43889602-7602-408a-890f-34db2f8412f3"
# [12] "ab461b9a-bfdd-4fee-b6ec-9a4141bf8849"
# [13] "f2bba867-479b-4f46-8458-73093f1055c0"
# [14] "adb1870e-2caa-4aed-b575-1f1a68bed2aa"

Also the case for other municipalities (output omitted)

tmp <- sapply(split(geoData, geoData$gemeente_afschot_locatie), function(iData) {
    if (length(unique(iData$provincie)) > 1) {
      cat("\n\n", unique(iData$gemeente_afschot_locatie), "\n")
      print(xtabs(~ iData$provincie + iData$afschotjaar, drop.unused.levels = TRUE))
    } 
  })

Git SHA (after 0.3.1) GIT commit

@SanderDevisscher Could you check whether this is also the case in your input file "rshiny_reporting_data_geography.csv" or share this file with me? I checked with the latest input file I have locally and there this issue does not occur.

SanderDevisscher commented 6 months ago

@mvarewyck The issue exists in my local file as well. This issue is due to some issue in the georef - script, which completes some missing spatial data. The issue was allready fixed in the past but I haven't had the chance to do a complete rerun thus resulting in some historical data with incorrect data. I'll look into doing a complete rerun in the future.

I did find another issue concerning the historical data which should be fixed in issue 1112 from the backoffice.