Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
geopat
geopat
Commits
6e4c1f4d
Commit
6e4c1f4d
authored
Apr 11, 2019
by
Dumoulin Nicolas
Browse files
extreme cases (no vegetables or all Bdv fullfilled)
parent
f05f13e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
scenariosAleatoires/proximite.py
View file @
6e4c1f4d
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment