inbo / niche_vlaanderen

Python package to run the NICHE Vlaanderen model
https://inbo.github.io/niche_vlaanderen/
MIT License
5 stars 2 forks source link

Validation: problem when more than once same niche veg type in a polygon #314

Closed cecileherr closed 1 year ago

cecileherr commented 1 year ago

When the same vegetation type occurs several times in a polygon, the total effective area is not correct. I suspect other derived variables could also be wrong (but not tested yet) This can happen in a real dataset, e.g. in the habitat map for Brasschaat BWK_2020_clip_Brasschaat.shp for polygon with TAG = 629464_v2020: both 4010,4030 and 4010 are present and both will be translated into niche vegetation type 22.

Here is an example with a dummy dataset:

from niche_vlaanderen.validation import NicheValidation

simplebr = nv.Niche()
simplebr.run_config_file("../tests/data/bwk/niche_brasschaat/simple.yaml")

no_simplebr_fkok = NicheValidation(niche=simplebr, map= "bwk_fake_extentok.shp") # see zip attached
no_simplebr_fkok.overlay()

no_simplebr_fkok.area_effective

For shape_id = 6 (polygon = ca 33 ha with 80% 4010 and 20% 4010, 4030):

bwk_fake_extentok.zip

johanvdw commented 1 year ago

I can confirm the issue:

>>> no_simplebr_fkok.map.iloc[6]

id                                                            7
HAB1                                                       4010
HAB2                                                  4010,4030
HAB3                                                       None
HAB4                                                       None
HAB5                                                       None
pHAB1                                                        80
pHAB2                                                      20.0
pHAB3                                                       NaN
pHAB4                                                      None
pHAB5                                                      None
area_ha                                               33.874943
geometry      POLYGON ((159967.1008254092 221298.9891029091,...
area_shape                                            33.876981
NICH_1_1                                                   22.0
NICH_1_2                                                    NaN
NICH_2_1                                                   22.0
NICH_2_2                                                   28.0
NICH_3_1                                                    NaN
NICH_3_2                                                    NaN
NICH_4_1                                                    NaN
NICH_4_2                                                    NaN
NICH_5_1                                                    NaN
NICH_5_2                                                    NaN
Name: 6, dtype: object

no_simplebr_fkok.area_effective.iloc[6]
vegetation
2          NaN
8          NaN
22    6.775396
23         NaN
24         NaN
28    6.775396
Name: 6, dtype: float64
cecileherr commented 1 year ago

just as a reference in the future: this a better version of test shapefile: bwk_fake_extentok.zip