inbo / niche_vlaanderen

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

Validation: values area pot/nonpot #328

Closed cecileherr closed 1 year ago

cecileherr commented 1 year ago

I tried to replace hab_nich_join.csv by a custom version hab_niche_join_22_23.csv with all the types previously defined as

I get strange results for area_pot/non pot

Using my test vegetation map bwk_fake_extentok.zip with Brasschaat (you will need to adapt the paths):

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

# validation
from niche_vlaanderen.validation import NicheValidation
no_simplebr_fkok_2223 = NicheValidation(niche=simplebr, map= path_ch + "testcase_extra/brasschaat/bwk/bwk_fake_extentok.shp",
                                        mapping_file= path_ch +"system_tables/hab_niche_join_22_23.csv")
no_simplebr_fkok_2223.overlay()

# (slechte) kaart met potenties én vegetatiekaart voor type 28 
output_niche_28 = simplebr.plot(28)
# get bounds van de vegetatiekaart
xmin, ymin, xmax, ymax = no_simplebr_fkok_2223.map.total_bounds
output_niche_28.set_xlim(xmin-25, xmax+25) # 25 = buffer around the limits
output_niche_28.set_ylim(ymin-25, ymax+25)
mymap = no_simplebr_fkok_2223.map.boundary.plot(ax=output_niche_28)
no_simplebr_fkok_2223.map.apply(lambda x: mymap.annotate(text=str(x['id']-1) + "\n" + 
                                                        str(x['pHAB1']) + "% " + x['HAB1'] + "\n" + 
                                                     str(x['pHAB2']) + "% " + str(x['HAB2']) + "\n" + 
                                                     str(x['pHAB3']) + "% " + str(x['HAB3']) + "\n" + 
                                                     str(round(x['area_shape'])) + " ha", 
                                                 xy=x.geometry.centroid.coords[0], 
                                                 ha='center',
                                                    color = "magenta"), 
                           axis=1);
# shape 0 50% type 28 (vroeger 50% 22)
# shape 1 20% 28 (vroeger 20% 22)
# shape 2 nvt
# shape 3 95% 28 (vroeger 60% 22 en 35% 23)
# shape 4 40% 28 (vroeger 40% 22)
# shape 5 100 % 28 (vroeger 100% 22 en 20 % 28)

# show tables for area_pot and nonpot
no_simplebr_fkok_2223.area_pot
no_simplebr_fkok_2223.area_nonpot

# compare with values in table with potential_presence
no_simplebr_fkok_2223.potential_presence

shape_id 3 = 119 ha calculated area_pot 28 = 28 ha (while potential_presence type 28/present was 14) calculated area_nonpot 28 = 211 ha (while potential_presence type 28/not present was 105) area_pot 28 + area_nonpot 28 => in total much more than 119 ha

(maybe related to https://github.com/inbo/niche_vlaanderen/issues/314?)

cecileherr commented 1 year ago

type28