Commit 6e4c1f4d authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

extreme cases (no vegetables or all Bdv fullfilled)

parent f05f13e4
......@@ -25,16 +25,20 @@ class Proximite:
'''
# get area of "fruits et légumes" in the scenario
flSurfByBdv = patches[patches['cultgeopat']=='Fruits et légumes'].groupby('Bdv').agg({'SURF_PARC':sum})
result = flSurfByBdv.div(self.targetSurfByBdv,axis=0)
# put 0 where target is reached
result = result.where(result<1,0).sum() / result.where(result<1).count()
return result.values[0]
result = flSurfByBdv.div(self.targetSurfByBdv,axis=0).fillna(0)
if result.where(result<1).count().sum() == 0:
# All Bdv are fullfilled
result = 1
else:
# put 0 where target is reached and computing mean
result = result.where(result<1,0).sum() / result.where(result<1).count()
result = result.values[0]
return result
if __name__ == '__main__':
import geopandas as gpd
import pandas as pd
patches = gpd.GeoDataFrame.from_file("../output/PAT_patches/PAT_patches.shp", encoding='utf-8')
patches = patches[patches['cultgeopat']!='Non Considérée']
target = pd.read_csv('../resources/targetPAT.csv', sep=';',index_col=0)
targetRatio = (target['2050']-target['2016'])/target['2016']
targetPAT = patches.groupby('cultgeopat')['SURF_PARC'].sum()*(1+targetRatio)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment